A reviewer is asking me to test for homoscedasticity with "appropriate tests", as opposed to visual inspection of residual plots. I haven't found any such test (I guess he wants a p-value). Does such a test exist and if not, is there something I can cite to justify not presenting a p-value?
Yes you could use for example Levene's test using the
leveneTest() function from the
car package. Here's an example with the
Machines dataset from the
library(lme4) library(nlme); data(Machines) library(car) mod <- lmer(score ~ Machine + (1|Worker), data=Machines) > leveneTest(residuals(mod) ~ Machines$Machine) Levene's Test for Homogeneity of Variance (center = median) Df F value Pr(>F) group 2 0.0811 0.9222 51
Since the result is not significant, the assumption of equal variances (homoscedasticity) is met.
?leveneTest for more options.
Let's compare this with a boxplot of the residuals:
boxplot(residuals(mod) ~ Machines$Machine)
Since the reviewer seems to want a "formal test", it will probably be difficult to convince him accepting your visual inspection, despite, in my opinion, this would be the way to go. Maybe someone else has an actual reference why checking those assumptions visually is superior compared to "formal tests".
Edit to address comment by @D_Williams below:
A good and strongly cited paper by Zuur et al. 2010 may help to convince your reviewer regarding visual inspection of residuals to test for homogeneity of variances. Also here's is the link to the book Mixed Effects Models and Extensions in Ecology with R.