| perform_regression_test {BootstrapTests} | R Documentation |
Perform a test on the slope coefficient of a univariate linear regression
Description
This function performs a bootstrap regression test for given data X,Y.
The null hypothesis corresponds of a slope coefficient of zero, versus the
alternative hypothesis of a non-zero slope coefficient.
It uses an independence/null bootstrap "indep", a non-parametric "NP",
a residual bootstrap "res_bs", a fixed design bootstrap "fixed_design_bs",
a fixed design null bootstrap "fixed_design_bs_Hnull", a hybrid null
bootstrap "hybrid_null_bs" as bootstrap resampling schemes to perform
the bootstrap. This function gives the corresponding p-values, the true test
statistic and the bootstrap-version test statistics. Furthermore, it also
gives the estimated slope.The default (and valid) method implemented
in this function is the null bootstrap, together with the equivalent test
statistic. Via the bootstrapOptions argument, the user can specify other
bootstrap resampling schemes and test statistics.
Usage
perform_regression_test(
X,
Y,
nBootstrap = 100,
show_progress = TRUE,
bootstrapOptions = NULL
)
Arguments
X |
numeric univariate input vector resembling the independent variables |
Y |
numeric univariate input vector the dependent variables |
nBootstrap |
numeric value of the amount of bootstrap resamples |
show_progress |
logical value indicating whether to show a progress bar |
bootstrapOptions |
This can be one of
A warning is raised if the given combination of |
Value
A class object with components
-
pvals_dfa dataframe of p-values and bootstrapped test statistics:These are the p-values for the combinations of bootstrap resampling schemes, test statistics (centered and equivalent).
It also contains the vectors of bootstrap test statistics for each of the combinations.
-
true_stata named vector of size 1 containing the true test statistic. -
nBootstrapNumber of bootstrap repetitions. -
datanamed list of the used input data, i.e. X and Y. -
nameMethodstring for the name of the method used. -
betanumeric value of the estimated slope of the regression model.
References
Derumigny, A., Galanis, M., Schipper, W., & van der Vaart, A. (2025). Bootstrapping not under the null? ArXiv preprint, doi:10.48550/arXiv.2512.10546
See Also
perform_GoF_test,perform_independence_test.
The print and plot methods, such as plot.bootstrapTest.
Examples
n <- 100
# Under H1
X_data <- rnorm(n)
Y_data <- X_data + rnorm(n) #Y = X + epsilon
result <- perform_regression_test(X_data, Y_data, nBootstrap = 100,
bootstrapOptions = list(type_boot = "indep",
type_stat = "eq"))
print(result)
plot(result)
# Under H0
X_data <- rnorm(n)
Y_data <- 0 * X_data + rnorm(n) # (as b = 0 under H0)
result <- perform_regression_test(X_data, Y_data, nBootstrap = 100)
print(result)
plot(result)