# Multilevel regression question: can you use level 2 variable as a predictor variable?

I was just reading a paper in the field of education and there was a part I couldn't comprehend. The author did a multilevel regression analysis with the data which was nested in a school level. So that the 2nd level was school. The dependent variable was school violence.

The syntax in R would be like

lmer(violence ~ (1|schoolid), data=data)


But the thing really confused me was that the author also included the "private school" variable as a predictor variable in their analysis, saying that being private school would have different effects on school violence. So that the author included a binary variable (private school=1, public school=0) as a predictor variable. The syntax would be:

lmer(violence ~ private_school + (1|schoolid), data=data)


But isn't the school effect already accounted by specifying that the data is nested in a school level? Is it a statistically correct approach? I would really appreciate if you could answer my query.

• You should include a citation for the paper you refer to. Otherwise you get a lot of answers along the lines of "... what they did is probably ... ". This guessing is not very helpful, and of course, might not be what the authors actually did. Dec 3, 2022 at 15:48
• Also, you could phrase the hypothesis more carefully. This analysis only tells you something about association between the type of school and violence. Consider the difference between what you wrote: "being private school would have different effects on school violence" and what @DemetriPananos wrote: "the expected violence is different between private and non-private schools". There is difference in interpretation that is subtle but meaningful and important. Dec 3, 2022 at 15:56

You are correct that including a variable for "private school" would be colinear if the authors had included a set of dummy variables for each school. But that's not what they meant by staying that they treat the data (on students presumably) as being "nested" at the school level. Rather, they probably meant that they are treating "school" not as a variable, but as another type of observation - like "student" - and just like you can have student level variables, you can also have school level variables. This is what makes it a "multilevel" model - the data are at two different levels (students and schools).

Mathematically, the way they did this is (probably) to run what is sometimes called a random effects (or mixed effects) model. "School" is not a variable in the model (if they did that we would - confusingly - call it a "fixed effects model"), but rather the model has two error terms - one at the individual level and one at the school level.

Here's a more detailed explanation about the distinction between fixed and random effects models in a "students nested within schools" context.

• Thanks a lot! Now it's much clearer!! Dec 2, 2022 at 16:33

This sounds fine to me.

As written, the second model assumes that expected violence is different between private and non-private schools. Within private and non-private schools, violence is assumed to vary by school.

• Isn't the between school variability independent of the school type? Dec 3, 2022 at 16:36
• @dipetkov Yes. Some of the between school variability can be explained away by private school status. Dec 3, 2022 at 16:42
• Maybe my question wasn't expressed clearly, so I try again. "Within private schools, violence is assumed to vary by school." seems to suggest that this is not the case for public schools. Does the second model treat the between school variances differently, for public and private schools? Dec 3, 2022 at 16:46
• @dipetkov Private schools are a specific example. The same is true of all schools. Dec 3, 2022 at 17:00
• @dipetkov I've added explicit reference to private and non-private schools in my answer for clarification Dec 3, 2022 at 17:00