简体   繁体   English

Hotelling 的 T^2 检验的幂

[英]Power for Hotelling's T^2 test

I am trying to estimate the performance of the hotelling's T^2 test.我试图估计hotelling 的T^2 测试的性能。 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.我注意到在电源 package 中没有酒店的 T^2 选项。 So how can I compute the power of that test manually or any tips to compute a type II error of the test?那么如何手动计算该测试的功效或计算测试 II 型错误的任何提示?

Here is a way of simulating Hotelling's T-squared power.这是一种模拟 Hotelling 的 T 平方幂的方法。 The question's code for the rate of Type I errors is an adaptation of the code in this Cross Validated post .该问题的 I 类错误率代码是对这个 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) .等多元均值的 null 为假,一个是rep(0, 10)另一个是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")

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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