Mass-univariate bootstrap-based inference for contrasts in a linear model
Source:R/bootstrapCalibration.R
bootstrap_permutation.Rd
Compute the marginal null t-statistics for a set of contrasts and their (two-sided) p-value by bootstrapping the residuals
Usage
bootstrap_permutation(
Y,
X,
C,
alternative = c("two.sided", "less", "greater"),
B = 1000,
replace = TRUE
)
Arguments
- Y
A data matrix of size $n$ observations (in row) and $D$ features in columns
- X
A design matrix of size $n$ observations (in row) and $p$ variables (in columns)
- C
A contrast matrix of size $L$ tested contrasts (in row) and $p$ columns corresponding to the parameters to be tested
- alternative
A character string specifying the alternative hypothesis. Must be one of "two.sided" (default), "greater" or "less".
- B
An integer value, the number of bootstraps
- replace
A Boolean value. If TRUE (default) then the residuals are sampled with replacement (i.e. a bootstrap), if FALSE then they are sampled without replacement resulting in a permutation of the data
Details
Performs lm_test
for each permutation. Based on a python
implementation available in the pyperm
package:
https://github.com/sjdavenport/pyperm/
References
Davenport, S., Thirion, B., & Neuvial, P. (2025). FDP control in mass-univariate linear models using the residual bootstrap. Electronic Journal of Statistics, 19(1), 1313-1336.
Examples
N <- 100
p <- 2
D <- 2
X <- matrix(0, nrow = N, ncol = p)
X[, 1] <- 1
X[, -1] <- runif(N*(p-1), min = 0, max = 3)
beta <- matrix(0, nrow = p, ncol = D)
epsilons <- matrix(rnorm(N * D), nrow = N, ncol = D)
Y <- X %*% beta + epsilons
C <- diag(p)
resLM <- bootstrap_permutation(Y = Y, X = X, C = C, B = 10)