I am working on a factorial design (3 factors) and want to use bootstrapped estimates of the effect size. I am unable to execute this with the boot function of R.
Model: Y ~ factor(A) * factor(B) * C
Here is the sample data and the code I am using (based on this), along with the error it generates.
ws <- data.frame(A = c(rep(0.02, 10), rep(0.4, 10), rep(0.8, 10)),
B = c(rep(2, 10), rep(6, 10), rep(11, 10)),
C = c(rep("a", 15), rep("b", 15)),
Y = sample(x = 30:9000, size = 30, replace = TRUE))
es_boot <- function(formula, data, i) {
data_resamp <- data[i,] # Resample rows
model <- aov(formula, data = data_resamp)
es <- lsr::etaSquared(model, type = 1)[, "eta.sq"] # Extract effect sizes
return (as.vector(es))
}
esboot_run <- boot(statistic = es_boot,
formula = "Y ~ factor(A) * factor(B) * C",
data = ws,
R = 2000)
**Error: $ operator is invalid for atomic vectors**
Where is the mistake?