MyNixOS website logo
Description

Run Permutation Tests and Construct Associated Confidence Intervals.

Implements permutation tests for any test statistic and randomization scheme and constructs associated confidence intervals as described in Glazer and Stark (2024) <doi:10.48550/arXiv.2405.05238>.

permutest

The goal of permutest is to allow users to run permutation tests and construct associated confidence intervals for any test statistic and any set of permutations.

Installation

You can install the development version of permutest from GitHub with:

# install.packages("devtools")
devtools::install_github("akglazer/permutest")

Example

This is a basic example which shows you how to use the permutation test function with a difference in means test statistic:

library(permutest)

data <- data.frame(group = c(rep(1, 10), rep(2, 10)),
                     outcome = c(rep(1, 10), rep(1, 10)))

output <- permutation_test(df = data, group_col = "group", outcome_col = "outcome",
                   test_stat = "diff_in_means", perm_func = permute_group,
                   alternative = "greater", shift = 0, reps = 10,
                   return_perm_dist = F, return_test_dist = T, seed = 42)

Alternatively, for the two-sample problem with difference in means test statistic, you can use the function two_sample() (and for the one-sample problem you can use one_sample()):

output <- two_sample(x = c(10, 9, 11), y = c(12, 11, 13), alternative = "less", seed = 42)

The following is an example of how to construct a confidence interval for a shift parameter in the two-sample problem:

x <- c(35.3, 35.9, 37.2, 33.0, 31.9, 33.7, 36.0, 35.0,
         33.3, 33.6, 37.9, 35.6, 29.0, 33.7, 35.7)
y <- c(32.5, 34.0, 34.4, 31.8, 35.0, 34.6, 33.5, 33.6,
         31.5, 33.8, 34.6)
df <- data.frame(outcome = c(x, y), group = c(rep(1, length(x)), rep(0, length(y))))

output <- permutation_test_ci(df, "group", "outcome", strata_col = NULL,
                      test_stat = "diff_in_means",
                      perm_func = permute_group,
                      upper_bracket = NULL,
                      lower_bracket = NULL,
                      cl = 0.95,
                      e = 0.01,
                      reps = 100000,
                      seed = 42)
Metadata

Version

1.0.0

License

Unknown

Platforms (77)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-freebsd
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64-windows
  • 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