Title: | Testing the Equality of Two Covariance Matrices |
---|---|
Description: | Tests the equality of two covariance matrices, used in paper "Two sample tests for high dimensional covariance matrices." Li and Chen (2012) <arXiv:1206.0917>. |
Authors: | Jun Li [aut, cre], Song Xi Chen [aut], Lingjun Li [ctb], Clay James [ctb] |
Maintainer: | Jun Li <[email protected]> |
License: | GPL-2 |
Version: | 1.0 |
Built: | 2024-10-31 19:55:45 UTC |
Source: | CRAN |
R code for testing the equality of two covariance matrices, used in paper "Two sample tests for high dimensional covariance matrices".
equalCovs(sam1, sam2, size1, size2)
equalCovs(sam1, sam2, size1, size2)
sam1 |
First sample, it must be array with structure size1*p, p is the dimension of data. |
sam2 |
Second sample, it must be array with structure size2*p, p is the dimension of data. |
size1 |
sample size of first sample |
size2 |
sample size of second sample |
test statistics and p-values
test_stat |
test statistics |
pvalue |
p-values |
Jun Li and Song Xi Chen
library(mvtnorm) p<-700 # the dimension of multivariate theta1<-2 theta2<-1 mat1<-diag(theta1,p-1) mat2<-diag(theta1+theta1*theta2,p-1) mat3<-diag(theta2,p-2) mat1<-rbind(mat1,rep(0,p-1)) mat2<-rbind(mat2,rep(0,p-1)) mat3<-rbind(mat3,rep(0,p-2),rep(0,p-2)) mat1<-cbind(rep(0,p),mat1) mat2<-cbind(rep(0,p),mat2) mat3<-cbind(rep(0,p),rep(0,p),mat3) sigma1<-mat1+t(mat1)+diag(1+theta1^2,p) sigma2<-mat2+t(mat2)+mat3+t(mat3)+diag(1+theta1^2+theta2^2,p) size1<-80 size2<-80 sam1<-rmvnorm(size1,runif(p,0,5),sigma1) # generate the samples sam2<-rmvnorm(size2,runif(p,-3,3),sigma2) equalCovs(sam1,sam2,size1,size2)
library(mvtnorm) p<-700 # the dimension of multivariate theta1<-2 theta2<-1 mat1<-diag(theta1,p-1) mat2<-diag(theta1+theta1*theta2,p-1) mat3<-diag(theta2,p-2) mat1<-rbind(mat1,rep(0,p-1)) mat2<-rbind(mat2,rep(0,p-1)) mat3<-rbind(mat3,rep(0,p-2),rep(0,p-2)) mat1<-cbind(rep(0,p),mat1) mat2<-cbind(rep(0,p),mat2) mat3<-cbind(rep(0,p),rep(0,p),mat3) sigma1<-mat1+t(mat1)+diag(1+theta1^2,p) sigma2<-mat2+t(mat2)+mat3+t(mat3)+diag(1+theta1^2+theta2^2,p) size1<-80 size2<-80 sam1<-rmvnorm(size1,runif(p,0,5),sigma1) # generate the samples sam2<-rmvnorm(size2,runif(p,-3,3),sigma2) equalCovs(sam1,sam2,size1,size2)