Homoscedascity test for Two-Way ANOVA

aL3xa picture aL3xa · May 29, 2010 · Viewed 17.6k times · Source

I've been using var.test and bartlett.test to check basic ANOVA assumptions, among others, homoscedascity (homogeniety, equality of variances). Procedure is quite simple for One-Way ANOVA:

bartlett.test(x ~ g)  # where x is numeric, and g is a factor
var.test(x ~ g)

But, for 2x2 tables, i.e. Two-Way ANOVA's, I want to do something like this:

bartlett.test(x ~ c(g1, g2))  # or with list; see latter:
var.test(x ~ list(g1, g2))

Of course, ANOVA assumptions can be checked with graphical procedures, but what about "an arithmetic option"? Is that, at all, manageable? How do you test homoscedascity in Two-Way ANOVA?

Answer

Ian Fellows picture Ian Fellows · May 29, 2010

Hypothesis testing is the wrong tool to use to asses the validity of model assumptions. If the sample size is small, you have no power to detect any variance differences, even if the variance differences are large. If you have a large sample size you have power to detect even the most trivial deviations from equal variance, so you will almost always reject the null. Simulation studies have shown that preliminary testing of model assumption leads to unreliable type I errors.

Looking at the residuals across all cells is a good indicator, or if your data are normal, you can use the AIC or BIC with/without equal variances as a selection procedure.

If you think there are unequal variances, drop the assumption with something like:

library(car)
model.lm <- lm(formula=x ~ g1 + g2 + g1*g2,data=dat,na.action=na.omit)
Anova(model.lm,type='II',white.adjust='hc3')

You don't loose much power with the robust method (hetroscedastic consistent covariance matrices), so if in doubt go robust.