CommencerCommencer gratuitement

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

Afficher le cours

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.

Exercice interactif pratique

Essayez cet exercice en complétant cet exemple de code.

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


# Look at the summary
summary(___)
Modifier et exécuter le code