1
$\begingroup$

Suppose I have four linear mixed effects models as shown:

mod1 <- lmer(X ~ (1|D), data = df)
mod2 <- lmer(X ~ A + (1|D), data = df)
mod3 <- lmer(X ~ A + B + (1|D), data = df)
mod4 <- lmer(X ~ A + B + C + (1|D), data = df)

All models have the same random effects and each model just adds another new variable to the previous model, so I believe they fit the criteria for nested models? I want to compare the variance explained in the fixed effects of the response (X) between all the four models. My initial approach is to just compare all the models via an ANOVA as such:

anova(mod1, mod2, mod3, mod4)

However, from my understanding this would just compare mod1 vs mod2, then mod2 vs mod3, and mod3 vs mod4, however if I want to compare all combinations of models, i.e.:

  • mod1 vs mod2
  • mod1 vs mod3
  • mod1 vs mod4
  • mod2 vs mod3
  • mod2 vs mod4
  • mod3 vs mod4

Do I need to create separate ANOVAs for each of these comparisons, or is there a more efficient way to do this in R? Is there anything that needs to be taken into account when doing these comparisons when using the lmer package vs lm package (linear models)?

Thank you in advance.

$\endgroup$
3
  • $\begingroup$ Why not just use the information criteria (i.e., AIC or BIC)? Also, what do you mean variance explained? Which variance? That sitting within D or within the residual? $\endgroup$
    – Erik Ruzek
    Mar 30, 2020 at 3:39
  • $\begingroup$ @ErikRuzek By variance explaid I mean within the residual. $\endgroup$
    – T.Grover
    Mar 30, 2020 at 7:12
  • $\begingroup$ anova will not tell you how much residual variance was explained, as far as I know. I think you'll have to calculate that by hand. There are also packages available for this. See stats.stackexchange.com/questions/7240/…. The reason to run the anova code is to see the AIC and BIC values for all these models. $\endgroup$
    – Erik Ruzek
    Mar 30, 2020 at 12:49

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.