Question

I was wondering if there is a way in R to do an ANOVA with unequal variances?

Imagine the following example:

x <- c(10,11,15,8,16,12,20)
y <- c(10,14,18,25,28,30,35)

d <- c(x,y)
f <- as.factor(c(rep("a",7), rep("b",7)))

# Unequal variance:

t.test(x,y)$p.value
t.test(d~f)$p.value

# Equal variance:

t.test(x,y, var.equal=TRUE)$p.value
t.test(d~f, var.equal=TRUE)$p.value

anova(lm(d~f))[[5]]
summary(aov(lm(d~f)))[[1]][5]
summary(lm(d~f))[[4]][8]

As you can see from this example the different ways of performing an ANOVA in R, in case of two groups only, always result in a p-value identical to the one obtained by a t.test with equal variances. Again, is there a way to perform an ANOVA with unequal variances?

Was it helpful?

Solution

For this case there is oneway.test()

R> oneway.test(d~f)

    One-way analysis of means (not assuming equal variances)

data:  d and f 
F = 6.631, num df = 1.000, denom df = 8.339, p-value = 0.03179
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top