ranova

Simple ANOVA with bwtrim in WRS2 package throws error


For educational purposes, I try to do a simple robust ANOVA with WRS2 package in R. I want to compare variable var1 in two different conditions (A and B):

df <- data.frame(
  id = c(1, 1, 2, 2, 3, 3, 5, 5),
  condition = c("A", "B", "A", "B", "A", "B", "A", "B"),
  var1 = c(1.70, 0.80, 0.80, 1.78, 5.61, 1.53, 7.64, 3.92),
  var2 = c(0.85, 2.41, 1.50, 1.3, 0.45, 1.53, 0.00, 1.34)
  )
df$condition <- as.factor(df$condition)
library(WRS2)
bwtrim(formula = var1 ~ condition, id = id, data = df)

Unfortunately, the code causes an error which I can't interpret: Error in '[.data.frame'(mf, , 3) : undefined columns selected. What's wrong with my code or understanding of the bwtrim function?


Solution

  • According to the docs, bwtrim is

    designed for one between-subjects variable and one within-subjects variable

    You would need two categorical variables on the right hand side of your formula.

    If you are looking for a simple one-way repeated measures ANOVA for the trimmed means using the WRS2 package, try pairdepb

    pairdepb(df$var1, df$condition, df$id)
    # Call:
    # pairdepb(y = df$var1, groups = df$condition, blocks = df$id)
    # 
    #         psihat  ci.lower ci.upper    test     crit   sig
    # A vs. B   1.93 -23.19144 27.05144 1.60483 20.88889 FALSE