Linear mixed effect model- Birth rates data

Hierarchical and Mixed Effects Models in R

Richard Erickson

Data Scientist

Chapter outline

  • Random-effect intercept model
  • Random-effect slope model
Hierarchical and Mixed Effects Models in R

Birth rates data

  • Small populations subject to stochasticity
  • Random-effects one solution to this problem
  • Birth rates one such variable
Hierarchical and Mixed Effects Models in R

How does a mothers age impact birth rate?

  • Does a mother's age impact birth rate?
  • Marketing and policy implications
Hierarchical and Mixed Effects Models in R

Plot of birth rates against county size

Hierarchical and Mixed Effects Models in R

lmer syntax in R

library(lme4)
lmer(y ~ x + (Random-effect), data = my_data)
Hierarchical and Mixed Effects Models in R

Random-effect syntax

  • (1 | group): Random intercept with fixed mean
  • (1 | g1/g2): Intercepts vary among g1 and g2 within g1
  • (1 | g1) + (1 | g2): Random intercepts for 2 variables
  • x + (x | g): Correlated random slope and intercept
  • x + (x || g): Uncorrelated random slope and intercept
  • See lme4 for additional details
Hierarchical and Mixed Effects Models in R

Let's practice!

Hierarchical and Mixed Effects Models in R

Preparing Video For Download...