我想在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