1. Learn
  2. /
  3. Courses
  4. /
  5. Hierarchical and Mixed Effects Models in R

Connected

Exercise

Model comparison with ANOVA

Comparing models can be difficult. Many methods exist although these are beyond the scope of this course such as model selection (e.g., AIC).

Analysis of Variance (ANOVA) exists as a basic option to compare lmer models. The ANOVA tests to see if one model explains more variability than a second model. The ANOVA does this by examining the amount of variability explained by the models.

For example, you can see if Year predicts Crime in Maryland. To do this, build a null model with only County as a random-effect and a year model that includes Year. You can then compare the two models using the anova() function.

If Year explains a significant amount of variability, then the P-value will be less than your pre-specified threshold (usually 0.05).

Instructions 1/2

undefined XP
    1
    2
  • Build a model that only includes County as a random-effect.
  • Build a model that includes Year2 as a random-effect slope.
  • Compare null_model (first) to year_model (second) using anova().