Variance Homogeneity for a model created with lmerTest

311 views Asked by At

I have run the model:

model2 <- lmer(tas ~ station
              + (1|date), data = all5)

where station is a categorical variable with 4 levels. I want to check for variance homogeneity. I find the residuals from lmerresid <- resid(model2). If I run the levene test: leveneTest(lmerresid ~ all5$station) I get p = 0.6572 so it implies homogeneity of variances. If I make the boxplots it implies homogeneity of variances:

boxplot(lmerresid ~ all5$station)

enter image description here But if I plot residuals vs fited then there is sth wrong: #Plot vs factors

par(mfrow = c(1,1))
plot(lmerresid ~ fitted(model2))

enter image description here

Are the variances homogeneous?

1

There are 1 answers

0
MrSwaggins On

I'm not sure you use levene tests on mixed models (as opposed to lm()), though I could be wrong there.

THAT SAID

I have found the easiest way to test models for validity is to use library(performance).

performance(model2)

"Super easy, barely and inconvenience". I'm not going to say it's perfect* for what you have in mind, but it will run most (if not all) of the tests that you may need to check your model. This along with the standard lmer() output, should enable you to interpret your model.

* You will need to delve into the manual to understand all the appropriate uses of the tests.