我想在R中执行bootstrapped配对t检验。我尝试过使用参数配对t检验返回p < .05的多个数据集,但是当我运行bootstrap时,我得到的p值介于0.4和0.5。我运行这个不正确吗?如何在R中执行引导配对t检验?
differences<-groupA-groupB
t.test(differences) #To get the t-statistic e.g. 1.96
Repnumber <- 10000
tstat.values <- numeric(Repnumber)
for (i in 1:Repnumber) {
group1 = sample(differences, size=length(differences), replace=T)
tstat.values[i] = t.test(group1)$statistic
}
#### To get the bootstrap p-value compare the # of tstat.values
greater (or lesser) than or equal to the original t-statistic divided
by # of reps:
sum(tstat.values<=-1.96)/Repnumber
谢谢!
谢谢。引导时是否需要保留这些对?如果不是,我可以重写这个。 – Sebastian112