Test whether the covariance matrix is equal to a certain value. The null hypothesis is "H0: Sigma = Sigma0" or "H0: Sigma = sigma^2 * Sigma0".
Arguments
- data
The data matrix which is a matrix or data frame.
- Sigma0
The covariance matrix when the null hypothesis is true.
- ball
A boolean value. Default is FALSE. If FALSE, test whether the covariance matrix is Sigma0 (known), which means the null hypothesis is "H0: Sigma = Sigma0". If TRUE and the Sigma0 is a unit matrix, the Mauchly's ball test will be performed. If TRUE but Sigma0 (known) is not a unit matrix, the covariance matrix will be tested to see if it is sigma^2*Sigma0 (sigma^2 is unknown), which means the null hypothesis is "H0: Sigma = sigma^2 * Sigma0".
- alpha
The significance level. Default is 0.05.
- verbose
A boolean value. Default is TRUE. If TRUE, the null hypothesis will be displayed. If FALSE, the test will be carried out silently.
Value
An object of class "testResult", which is a list with the following elements: Return when ball is FALSE.
- Conclusion
The conclusion of the test.
- Stat
A data frame containing the statistics, p value and critical value.
- SampMean
The sample mean.
- SampA
The sample deviation.
- Df
The degree of freedom.
Return when ball is TRUE
- Conclusion
The conclusion of the test.
- Stat
A data frame containing the statistics, p value and critical value.
- SampMean
The sample mean.
- SampA
The sample deviation.
- sigma.hat
The estimation of sigma^2.
- Df
The degree of freedom.
References
Huixuan, Gao. Applied Multivariate Statistical Analysis. Peking University Press, 2005: pp.83-88.
Examples
data(iris)
X <- iris[, 1:4]
# carry out the test
test1 <- covTest.single(X, diag(1, 4))
test2 <- covTest.single(X, diag(1, 4), ball = TRUE)
test3 <- covTest.single(X, diag(2, 4), ball = TRUE)
test4 <- covTest.single(X, diag(1, 4), verbose = FALSE)
#> H0: Sigma = Sigma0
# get the elements
test1$Stat
#> Value p.value Critical.Value
#> Likelihood Ratio 3.829315e-223
#> Chi2 1.024268e+03 0 18.3070380532751
test2$Df
#> [1] "Chi2( 9 )"
test3$sigma.hat
#> [1] 0.5678088