我想在 R 中执行自举配对 t 检验。我已经尝试过使用参数配对 t 检验时返回 p<.05 的多个数据集,但是当我运行自举时,我得到的 p 值在 0.4 和 0.5 之间. 我运行不正确吗?
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
谢谢!