Fixed- and random-effect predictor

In the previous exercises, you fit mixed-effect models with different fixed- and random-effects.

Sometimes, a model can have the same predictor as both a fixed and random-effect. For example, perhaps you are interested in estimating the average effect the age of a mother at birth (AverageAgeofMother). Including the predictor as fixed-effect allows you to estimate the effect of a mother's age across all locations. Including the predictor as a random-effect allows you to simultaneously account (or correct) for different slope estimates among states.

This exercise is part of the course

Hierarchical and Mixed Effects Models in R

View Course

Exercise instructions

  • Construct a lmer() using AverageAgeofMother as a fixed-effect and AverageAgeofMother as a random-effect nested within State to predict BirthRate with the county_births_data. Make sure the fixed-effect goes before the random-effects in the formula.
  • Use summary() on the output.

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

# Construct a lmer() 
out <- lmer(___)


# Look at the summary
summary(___)