I have a small question about the concept behind hypothesis testing using bootstrap. Assume that I need to evaluate two independent population mean differences: population a and population b. My doubt is the following:
Should I apply bootstrap on a single population, and check the difference of the mean after that?
Mean[BOOT(a)-BOOT(b)]
Alternatively, should I compute di difference:
Mean(a)-Mean(b)
and then apply bootstrap?BOOT[Mean(a)-Mean(b)]
I used this code by using the second approach:
set.seed(123)
a <- rnorm(100)
b <- rnorm(100)
hist(a)
hist(b)
c = a-b
hist(c)
boot_1 = function(R,dati_oss){
n = length(dati_oss)
media_boot = vector("numeric",R)
for(i in 1:R){
ind = sample(1:n,replace=T)
media_boot[i] = mean(dati_oss[ind])
}
return(media_boot)
}
res=boot_1(500000,c)
hist(res)
stat = matrix(c(mean(c), mean(res), mean(res)-mean(c), sqrt(var(res)),
as.vector(quantile(res, c(0.025,0.975)))), 1, 6)
colnames(stat) = c("Observed", "Mean-boot", "Bias", "SE", "0.95LCI", "0.95UCI")
row.names(stat) = c("Mean")
stat
res=boot_1(500000,c)
. $\endgroup$ – gung - Reinstate Monica Jun 10 '19 at 15:04