ComeçarComece de graça

Exploring multiple-levels: Classrooms and schools

In the last exercise, the simple linear model you used did not account for the structure of the data. Students learn within classrooms and classrooms exist within schools, which means students within the same classroom are not independent. One solution is to collapse the data by taking a mean for each level. However, the method used to collapse the data can be important, especially for small or unequal-sized groups.

In this exercise, you will aggregate the gains in math scores (mathgain) three different ways. After summarizing the data, you will examine a linear model of the data at each level.

Este exercício faz parte do curso

Hierarchical and Mixed Effects Models in R

Ver curso

Exercício interativo prático

Experimente este exercício completando este código de exemplo.

# Summarize the student data at the classroom level
class_data <-
    student_data %>%
    group_by(classid, schoolid) %>%
    summarize(mathgain_class = mean(mathgain),
              mathknow_class = mean(mathknow),
              n_class = n(), .groups = "keep")

# Model the math gain with the student-level data
lm(___ ~ ___, data = ___)

# Model the math gain with the classroom-level data
lm(___ ~ ___, data = ___)
Editar e executar o código