使用带有R的引导程序计算p值
我使用“ boot”包来计算近似的两面自举p值,但是结果与使用t.test的p值相差太远。我无法弄清楚我在R代码中做错了什么。有人可以给我一个提示吗 time = c(14,18,11,13,18,17,21,9,16,17,14,15, 12,12,14,13,6,18,14,16,10,7,15,10) group=c(rep(1:2, each=12)) sleep = data.frame(time, group) require(boot) diff = function(d1,i){ d = d1[i,] Mean= tapply(X=d$time, INDEX=d$group, mean) Diff = Mean[1]-Mean[2] Diff } set.seed(1234) b3 = boot(data = sleep, statistic = diff, R = 5000, strata=sleep$group) pvalue = mean(abs(b3$t) > abs(b3$t0)) pvalue 两面自举的p值(pvalue)= 0.4804,但t.test的两面p值为0.04342。两个p值的差约为11倍。怎么会这样