เริ่มต้นใช้งานเริ่มต้นใช้งานได้ฟรี

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.

แบบฝึกหัดนี้เป็นส่วนหนึ่งของหลักสูตร

Hierarchical and Mixed Effects Models in R

ดูคอร์ส

คำแนะนำการฝึกหัด

  • 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.

แบบฝึกหัดเชิงโต้ตอบแบบลงมือทำ

ลองทำแบบฝึกหัดนี้โดยเติมโค้ดตัวอย่างนี้ให้สมบูรณ์

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


# Look at the summary
summary(___)
แก้ไขและรันโค้ด