get_perm: Get permutation statistics and p-values

View source: R/calibration.R

get_permR Documentation

Get permutation statistics and p-values

Description

Get a matrix of statistics and p-values under the null hypothesis obtained by repeated permutation of class labels (two-sample tests)

Usage

get_perm(
  X,
  categ,
  B,
  rowTestFUN = rowWelchTests,
  alternative = c("two.sided", "less", "greater")
)

Arguments

X

A matrix of m variables (hypotheses) by n observations

categ

An numeric vector of n values in ⁠0,1⁠ specifying the column indices of the first and second samples.

B

An integer value, the number of permutations to be performed

rowTestFUN

a vectorized testing function (same I/O as rowWelchTests)

alternative

A character string specifying the alternative hypothesis, to be passed to rowTestFUN. Must be one of "two.sided" (default), "greater" or "less".

Details

The element 'p.value' of the output is a ⁠m x B⁠ matrix whose entry i,j corresponds to ⁠p_{(i)}(g_j.X)⁠ with notation of the AoS 2020 paper cited below (section 4.5).

Examples

m <- 50
n <- 45
X <- matrix(rnorm(m*n), ncol = n, nrow = m)
categ <- rbinom(n, 1, 0.4)

B <- 10
set.seed(123)
perm0 <- sanssouci:::get_perm(X, categ, B, rowWelchTests)

# for this particular test 'get_perm' can be bypassed
set.seed(123)
null_groups <- replicate(B, sample(categ))
perm <- rowWelchTests(X, null_groups)
identical(perm0$p.value, perm$p.value)
identical(perm0$statistic, perm$statistic)
# Wilcoxon tests
set.seed(123)
perm0 <- sanssouci:::get_perm(X, categ, B, rowWilcoxonTests)
perm <- rowWilcoxonTests(X, null_groups)
identical(perm0$p.value, perm$p.value)
identical(perm0$statistic, perm$statistic)

pneuvial/sanssouci documentation built on Feb. 12, 2024, 4:18 a.m.