Package BootstrapTests
This package BootstrapTests implements several methods to perform bootstrap-based hypothesis testing procedures on three statistical problems: independence testing, testing the slope in a linear regression setting, and goodness-of-fit testing.
Installation
You can install the development version of BootstrapTests from
GitHub using the devtools package with:
# install.packages("devtools")
devtools::install_github("AlexisDerumigny/BootstrapTests")Examples
The following three subsections will showcase the use of the ‘BootstrapTests’ package for the independence hypothesis testing, testing whether or not the slope is zero in a linear regression setting, and goodness-of-fit testing. In particular, we will show the use of the functions that implement these:
perform_independence_test.Rperform_regression_test.Rperform_GoF_test.R
Independence testing
We perform a hypothesis test of statistical independence by means of
bootstrapping. The null hypothesis is that of independence between the
two random variables, versus the alternative of dependence between them.
This procedure gives a total of 8 combinations of bootstrap resampling
schemes (nonparametric and independent), test statistics (centered and
equivalent), and Kolmogorov-Smirnov or L2-type of true test statistic.
This function gives the corresponding p-values, the true test statistic
and the bootstrap-version test statistics. The default (and valid)
method implemented in this function is the null bootstrap, together with
the equivalent test statistic and Kolmogorov-Smirnov test statistic. Via
the bootstrapOptions argument, the user can specify other bootstrap
resampling schemes and test statistics.
library(BootstrapTests)
n <- 100
# Under H1
X1 <- rnorm(n)
X2 <- X1 + rnorm(n)
result <- perform_independence_test(
X1, X2, nBootstrap = 100,
bootstrapOptions = list(type_boot = "indep",
type_stat = "eq",
type_norm = "KS") )
print(result)
#>