【发布时间】:2016-03-03 18:03:26
【问题描述】:
我想在 R 中执行自举配对 t 检验。我已经对多个使用参数配对 t 检验时返回 p<.05 p>
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
谢谢!
【问题讨论】:
标签: r statistics statistics-bootstrap significance statistical-test