0

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?

buzaku
  • 167
  • 10
  • This is more of a software programming question and should be migrated to Stack Overflow where questions of this type are appropriate. Alternatively, you could post it on one of the many R user community sites or blogs. – Mike Hunter Jul 27 '17 at 13:23
  • Noted, will migrate and delete this post – buzaku Jul 27 '17 at 13:27

1 Answers1

1

I'll answer this here, since I don't see the migrated question on SO.

The problem is that formula needs to be changed to as.formula(formula) in the aov call.

Sal Mangiafico
  • 7,128
  • 2
  • 10
  • 24
  • Thank you, there is a 90 min limit before I could migrate! But now I don't need to migrate, I guess... – buzaku Jul 27 '17 at 14:31