| perform_independence_test {BootstrapTests} | R Documentation |
Perform a hypothesis test of independence
Description
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.
Usage
perform_independence_test(
X1,
X2,
my_grid = NULL,
nBootstrap = 100,
show_progress = TRUE,
bootstrapOptions = NULL
)
Arguments
X1, X2 |
numerical vectors of the same size. The independence test tests
whether |
my_grid |
the grid on which the CDFs are estimated. This must be one of
|
nBootstrap |
number of bootstrap repetitions. |
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_df: a dataframe of p-values and bootstrapped test statistics:These are the p-values for the 8 combinations of bootstrap resampling schemes (nonparametric and independent), test statistics (centered and equivalent), and Kolmogorov-Smirnov or L2-type of true test statistic.
It also contains the vectors of bootstrap test statistics for each of the combinations.
-
true_statsa named vector of size 2 containing the true test statistics for the L2 and KS distances. -
nBootstrapNumber of bootstrap repetitions. -
nameMethodstring for the name of the method used.
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_regression_test.
The print and plot methods, such as plot.bootstrapTest.
Examples
n <- 100
# Under H1
X1 <- rnorm(n)
X2 <- X1 + rnorm(n)
result <- perform_independence_test(
X1, X2, nBootstrap = 50,
bootstrapOptions = list(type_boot = "indep",
type_stat = "eq",
type_norm = "KS") )
print(result)
plot(result)
# Under H0
X1 <- rnorm(n)
X2 <- rnorm(n)
result <- perform_independence_test(X1, X2, nBootstrap = 50)
print(result)
plot(result)