如果 p 变量正态随机向量的样本具有理论平均值,我希望我可以通过 hotellings 测试证明。但是与 ks.test 的交叉检查,如果来自 HottelingsT2 函数的分布与 HottelingsT2-Test 使用的测试统计量的分布相匹配,则失败。这意味着模拟实验的平均值不是 0,但显然它们有。所以上下文应该有问题。有没有一些错误?
require(mvtnorm)
require(ICSNP)
subject<-50
treatment<-4
V<-matrix(c(644.03100226056, 184.319025225855, 572.5312199559, 143.106678641056, 184.319025225855, 73.5310268006399, 230.838267981476, 130.977532385651, 572.5312199559, 230.838267981476, 736.378779002912, 429.445506266528, 143.106678641056, 130.977532385651, 429.445506266528, 435.124191935888),treatment,treatment)
experiment<-list()
R<-3000
seed<-split(1:(R*subject),1:R)
for(i in 1:R){
e<-c()
for(j in 1:subject){
set.seed(seed[[i]][j])
e<-c(e,rmvnorm(mean=rep(0,treatment),sigma=V,n=1,method="chol"))
}
experiment<-c(experiment,list(matrix(e,subject,treatment,byrow=T)))
}
p.values<-c()
for(e in experiment){
fit<-lm(e~1)
p.values<-c(p.values,HotellingsT2(e, mu=rep(0,treatment))[["p.value"]])
}
ks.test(p.values, punif,alternative = "two.sided")