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.
Cet exercice fait partie du cours
Hierarchical and Mixed Effects Models in R
Instructions
- Construct a
lmer()usingAverageAgeofMotheras a fixed-effect andAverageAgeofMotheras a random-effect nested withinStateto predictBirthRatewith thecounty_births_data. Make sure the fixed-effect goes before the random-effects in the formula. - Use
summary()on the output.
Exercice interactif pratique
Essayez cet exercice en complétant cet exemple de code.
# Construct a lmer()
out <- lmer(___)
# Look at the summary
summary(___)