test_covariance {CovCorTest} | R Documentation |
Test for Covariance Matrices
Description
This function conducts statistical tests for hypotheses
regarding covariance matrices. Users can either select from predefined
hypotheses (e.g., equal covariance, equal trace, etc.) or
provide their own contrast matrix C
and vector Xi
for custom hypotheses.
It supports both bootstrap and Monte Carlo resampling methods to
obtain the p-value of the ANOVA-type statistic (ATS).
Usage
test_covariance(
X,
nv = NULL,
C = NULL,
Xi = NULL,
hypothesis = NULL,
A = NULL,
method = "MC",
repetitions = 1000
)
Arguments
X |
A list or a matrix containing the observation vectors. If a list,
each entry is a group, with observations as columns. If a matrix, all
groups are combined, and |
nv |
(Optional) A vector indicating group sizes, needed when |
C |
(Optional) A user-defined contrast matrix for testing custom
hypotheses. Must match dimensions with |
Xi |
(Optional) A numeric vector used in combination with |
hypothesis |
A character specifying one of the predefined hypotheses:
If |
A |
Optional scalar or matrix to define the hypothesis value when
|
method |
A character indicating the resampling method:
|
repetitions |
Number of repetitions to use for the resampling method (default: 1000, should be >= 500). |
Value
An object of class CovTest
.
References
Sattler, P., Bathke, A. C., and Pauly, M. (2022). "Testing hypotheses about covariance matrices in general MANOVA designs." Journal of Statistical Planning and Inference, 219, 134–146. doi:10.1016/j.jspi.2021.12.001
Examples
# Load the data
data("EEGwide", package = "MANOVA.RM")
vars <- colnames(EEGwide)[1:6]
X <- t(EEGwide[EEGwide$sex == "M" & EEGwide$diagnosis == "AD",vars])
# Testing the trace
C <- matrix(c(1,0,0,0,0,0,1,0,0,0,0,1,0,0,0,1,0,0,1,0,1),
nrow = 1, ncol = 21)
Xi <- 2
set.seed(31415)
test_covariance(X = X, nv = NULL, C = C, Xi = Xi, method = "BT",
repetitions = 1000)