Bootstrap p value significantly different from t-t

2019-06-11 16:35发布

问题:

I am trying to figure out whether there is significant difference between two sample sets by calculating the p-value through bootstrapping and the t-test. However, I get p = 0.49 when I do bootstrapping and 7.015e-11 when I use the t-test. I'm quite confused as to why there is such a large difference between the two p-values. Below is the code for my bootstrap:

diff <- function(data, k) {
    s = data[, 1:25]
    n = data[, 26:100]
    mean <- tapply(s[, k], n[, k], mean)
    mean[1] - mean[2]
}
b = boot(d, diff, 10000)
p = mean(abs(b$t) > abs(b$t0))