View source: R/cov1_2012Fisher.R
cov1.2012Fisher | R Documentation |
Given a multivariate sample X and hypothesized covariance matrix Σ_0, it tests
H_0 : Σ_x = Σ_0\quad vs\quad H_1 : Σ_x \neq Σ_0
using the procedure by Fisher (2012). This method utilizes the generalized form of the inequality
\frac{1}{p} ∑_{i=1}^p (λ_i^r - 1)^{2s} ≥ 0
and offers two types of test statistics T_1 and T_2 corresponding to the case (r,s)=(1,2) and (2,1) respectively.
cov1.2012Fisher(X, Sigma0 = diag(ncol(X)), type)
X |
an (n\times p) data matrix where each row is an observation. |
Sigma0 |
a (p\times p) given covariance matrix. |
type |
|
a (list) object of S3
class htest
containing:
a test statistic.
p-value under H_0.
alternative hypothesis.
name of the test.
name(s) of provided sample data.
fisher_testing_2012SHT
## CRAN-purpose small example smallX = matrix(rnorm(10*3),ncol=3) cov1.2012Fisher(smallX) # run the test ## empirical Type 1 error niter = 1000 counter1 = rep(0,niter) # p-values of the type 1 counter2 = rep(0,niter) # p-values of the type 2 for (i in 1:niter){ X = matrix(rnorm(50*5), ncol=50) # (n,p) = (5,50) counter1[i] = ifelse(cov1.2012Fisher(X, type=1)$p.value < 0.05, 1, 0) counter2[i] = ifelse(cov1.2012Fisher(X, type=2)$p.value < 0.05, 1, 0) } ## print the result cat(paste("\n* Example for 'cov1.2012Fisher' \n","*\n", "* empirical error with statistic 1 : ", round(sum(counter1/niter),5),"\n", "* empirical error with statistic 2 : ", round(sum(counter2/niter),5),"\n",sep=""))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.