Random-effect slopes
In the previous exercise, you estimated random-effect intercepts for each state. This allowed you to account for each state having its own intercept. During this exercise, you will estimate a random-effect slope for each state. For example, perhaps the log\(_{10}\)(total population of each county), LogTotalPop
, changes the birth rate of a county AND varies by state.
Recall from the video, a random-effect slope
may be estimated for each group
using (slope | group)
syntax with lmer()
.
During this exercise, fit a mixed-effects model estimating the effect of the mother's average age while accounting for state and total population as random-effects.
How do the outputs from this model compare to the previous model you built?
This exercise is part of the course
Hierarchical and Mixed Effects Models in R
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Include the AverageAgeofMother as fixed-effect and State as a random-effect
model_a <- lmer(BirthRate ~ ___ + (___), county_births_data)
tidy(___)
# Include the AverageAgeofMother as fixed-effect and LogTotalPop and State as random-effects
model_b <- lmer(BirthRate ~ ___ + (___), county_births_data)
tidy(___)