[R] Multilevel Modeling in R
David Roy
dmr02004 at gmail.com
Fri Jan 29 07:10:57 CET 2016
I am conducting a multilevel regression analysis on the effect of an
intervention on student test results, and am not sure how to implement the
necessary R code to correctly capture the nested structure.
The outcome measure for the study is whether a student passed or failed a
final exam. The structure of the data is students nested within schools,
and then schools nested within random assignment blocks. Treatment (i.e.,
the intervention) was implemented at the school-level. The covariates that
I am planning to use are prior year test scores (this is also a binary
variable for pass or fail), race, and gender.
My ideal output would show the impact of the treatment for each of the
random assignment blocks, and then the weighted average of the impact
across all of the random assignment blocks.
Based on my research thus far, it seems like the **lmer** function from the
**lme4** package would be the best route to go.
This is the code that I have tried:
# Fit multilevel regression with random assignment blocks
glmer2 <- glmer(Post_Test_Score ~ Treatment +
Pre_Test_Score +
(1 | School) +
(1 | Random_Assignment_Block),
data = StudyData,
family = binomial("logit"))
My two questions are the following:
1.) Given the nested structure of my data, would the above regression
output the correct coefficient for the impact of treatment across all
random assignment blocks?
2.) How would I code the interaction effect between Treatment and
Random_Assignment_Block in order to generate separate impact estimates for
each of the random assignment blocks?
[[alternative HTML version deleted]]
More information about the R-help
mailing list