Solved – Levene’s test with a two-way anova

I am trying to perform a levenetest on my two-way anova.

leveneTest(Score ~ Party + Group, data = Data)  

But R just screams at me saying

Error in leveneTest.formula(formula(y), data = model.frame(y), ...) :    Model must be completely crossed formula only. 

I think you are getting an error as your model does not include an interaction term. I would try first creating a model fit using the lm function:

fit <- lm(Score ~ Party + Group, data = Data) 

and then using the levene.test function in the s20x package as it is a little less finicky.


In saying all that, levene tests are actually a really poor way of checking equality of variance (EoV). They are overly sensitive to deviations, while ANOVAs are actually quite robust. You are better off just looking at a plot (i.e. plot(fit, which =1)) and visually assessing it for EoV. If it is for an assignment that requires it, then ignore the latter advice. Also, the samething goes for normality and the shapiro-wilks test….

Similar Posts:

Rate this post

Leave a Comment