View source: R/bootstrapCalibration.R
bootstrap_permutation | R Documentation |
Compute the marginal null t-statistics for a set of contrasts and their (two-sided) p-value by bootstrapping the residuals
bootstrap_permutation(
Y,
X,
C,
alternative = c("two.sided", "less", "greater"),
B = 1000,
replace = TRUE
)
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 |
Performs lm_test
for each permutation. Based on a python
implementation available in the pyperm
package:
https://github.com/sjdavenport/pyperm/
An array of permuted p-values of dimensions D \times L \times B
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.
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.