I would like to fit a one-way between-subject anova that assumes unequal variances between groups.
Reproducible example:
library(emmeans)
library(car)
set.seed(123)
n <- 50
DF <- data.frame(score = c(rnorm(n, sd = 10), rnorm(n, sd = 30), rnorm(n, sd = 40)),
treatment = rep(c("A", "B", "C"), each = n),
subject = 1:(n*3))
leveneTest(score ~ treatment, DF) # Shows heterogeneity of variance
mdl <- lm(score ~ treatment, data = DF)
emmeans(mdl, ~treatment) # same SE for all the means
# treatment emmean SE df lower.CL upper.CL
# A 0.344 3.99 147 -7.54 8.23
# B 4.392 3.99 147 -3.50 12.28
# C -10.156 3.99 147 -18.04 -2.27
# Confidence level used: 0.95
Is there a way to tweak lm
(or lmer
) to take into account unequal variance?