MyNixOS website logo
Description

Nonparametric Bootstrap Test with Pooled Resampling Card Game.

The card game War is simple in its rules but can be lengthy. In another domain, the nonparametric bootstrap test with pooled resampling (nbpr) methods, as outlined in Dwivedi, Mallawaarachchi, and Alvarado (2017) <doi:10.1002/sim.7263>, is optimal for comparing paired or unpaired means in non-normal data, especially for small sample size studies. However, many researchers are unfamiliar with these methods. The 'bootwar' package bridges this gap by enabling users to grasp the concepts of nbpr via Boot War, a variation of the card game War designed for small samples. The package provides functions like score_keeper() and play_round() to streamline gameplay and scoring. Once a predetermined number of rounds concludes, users can employ the analyze_game() function to derive game results. This function leverages the 'npboottprm' package's nonparboot() to report nbpr results and, for comparative analysis, also reports results from the 'stats' package's t.test() function. Additionally, 'bootwar' features an interactive 'shiny' web application, bootwar(). This offers a user-centric interface to experience Boot War, enhancing understanding of nbpr methods across various distributions, sample sizes, number of bootstrap resamples, and confidence intervals.

bootwar

‘bootwar’ aims to help users build their intuition about nonparametric bootstrap tests with pooled resampling, especially for independent and paired t-tests (Dwivedi, Mallawaarachchi, and Alvarado, 2017).

Inspired by the card game War, which has straightforward rules but can be time-consuming, ‘bootwar’ is a variant with smaller sample sizes. Here, after playing a user-defined number of rounds, a winner is determined through nonparametric bootstrap tests with pooled resampling as implemented in the npboottprm R package.

Installation

You can install the released version of ‘bootwar’ from CRAN:

install.packages("bootwar")

Install the development version of bootwar from GitHub using devtools:

# install.packages("devtools")
devtools::install_github("mightymetrika/bootwar")

Example

This example demonstrates how to play a five-round game of bootwar:

Initialization:

# Load bootwar
library(bootwar)

# Set up vectors for computer and player's cards and values
comp_cv <- vector(mode = "character")
comp_vv <- vector(mode = "numeric")
plyr_cv <- vector(mode = "character")
plyr_vv <- vector(mode = "numeric")

# Shuffle a 52 card standard deck from the 'mmcards' package
sdeck <- mmcards::shuffle_deck(seed = 150)
head(sdeck)
#>    rank suit card value
#> 35   10    H  10H 10.50
#> 25    K    D   KD 13.25
#> 31    6    H   6H  6.50
#> 5     6    C   6C  6.00
#> 27    2    H   2H  2.50
#> 44    6    S   6S  6.75

Play the First Round:

rres <- play_round(cdeck = sdeck,
                   plyr_cv = plyr_cv, plyr_vv = plyr_vv,
                   comp_cv = comp_cv, comp_vv = comp_vv)

Continue the Game for Four More Rounds:

for (i in 1:4) {
  rres <- play_round(cdeck = rres$updated_deck,
                     plyr_cv = rres$plyr_cv, plyr_vv = rres$plyr_vv,
                     comp_cv = rres$comp_cv, comp_vv = rres$comp_vv)
}

# Ensure 10 cards have been dealt
nrow(rres$updated_deck)
#> [1] 42

Analyze the Game:

Use analyze_game() to evaluate the results. In this example, we’ll apply the paired t-test, but users can opt for the independent t-test by setting mode to ‘t’. Modify the conf.level parameter to change the confidence interval (think of this as a level which controls the amount of draws).

gres <- analyze_game(plyr_vv = rres$plyr_vv, comp_vv = rres$comp_vv,
                     mode = "pt", nboot = 1000, seed = 150, conf.level = 0.05)

# Display game results
gres$winner
#> [1] "Computer Wins"
gres$bootstrap_results$effect.size
#> [1] -0.25
gres$bootstrap_results$ci.effect.size
#> 47.5% 52.5% 
#> -0.15  0.05
gres$bootstrap_results$p.value
#> [1] 0.838

For a more streamlined gameplay experience, the bootwar() function launches an interactive Shiny web application.

Users can also customize the game using an anonymous function for deck definition, as showcased in the anonymous-bootwar vignette. Users can also customize the game by using an anonymous function to define a different deck for each player, as showcased in the interleaved-bootwar vignette.

References

Dwivedi AK, Mallawaarachchi I, Alvarado LA (2017). “Analysis of small sample size studies using nonparametric bootstrap test with pooled resampling method.” Statistics in Medicine, 36 (14), 2187-2205.

Metadata

Version

0.2.1

License

Unknown

Platforms (75)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows