I have used bootstrapping (percentile method) to calculate the confidence interval for the estimated mean of a set. I have now divided my data into two groups (a and b), and I want to test if the mean value in each group is different. I have considered the wilcoxon rank sum test, but would prefer a method similar to the bootstrap below.
library(boot)
set.seed(1)
value <- runif(100)
grp <- sample(c("a","b"), 100, replace = TRUE)
df <- data.frame(grp, value)
bootstrap_data <- function (data, func = mean, R = 10000) {
boot_func <- function(x, d) {
return(func(x[d]))
}
set.seed(1)
boot(data, boot_func, R = R)
}
bootstrap_ci <- function (data, func = mean, R = 10000) {
boot_data <- bootstrap_data(data, func, R)
boot.ci(boot_data, type="perc")
}
bootstrap_ci(value)
# 95% ( 0.4648, 0.5700 )