简体   繁体   中英

Power for Hotelling's T^2 test

I am trying to estimate the performance of the hotelling's T^2 test. I simulate various test from assumptions of normality and also equal covariance matrix. I succeed in computing the level of the test with the following formula.

#Generate two groups with equal multivariate vector of means but different covariances
## From the multivariate normal distributions
library(MASS)
set.seed(123)
X<-mvrnorm(50,rep(0,10),diag(rep(1,10)))
Y<-mvrnorm(50,rep(0,10),diag(rep(3,10)))

#Two sample Hotelling T^2 test
library(ICSNP)
HotellingsT2(X, Y)

# Performance of the test
## Significant level
n=10000 # testing 10,000 times
t1err=0
for (i in 1:n){
   X<-mvrnorm(50,rep(0,10),diag(rep(1,10)))
   Y<-mvrnorm(50,rep(0,10),diag(rep(3,10)))
   if (((HotellingsT2(X, Y))$p.value)<=0.05) (t1err=t1err+1) 
}
cat("The significance level in percentage is", (t1err/n)*100,"%")

Now my aim is to compute the power of the test. I notice there is no option for hotelling's T^2 in the power package. So how can I compute the power of that test manually or any tips to compute a type II error of the test?

Here is a way of simulating Hotelling's T-squared power. The question's code for the rate of Type I errors is an adaptation of the code in this Cross Validated post . I have also adapted that code, simplifying it a bit.

The null of equal multivariate means is false, one is rep(0, 10) and the other is rep(2, 10) . Unlike in the question's code, the covariance matrices are equal.

set.seed(123)
pval <- replicate(n, {
  X <- mvrnorm(50, rep(0, 10), diag(rep(1, 10)))
  Y <- mvrnorm(50, rep(2, 10), diag(rep(1, 10)))
  HotellingsT2(X, Y)$p.value
})
t2err <- mean(pval > 0.05)
cat("The test power in percentage is", (1 - t2err)*100,"%\n")

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM