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.

  • $\begingroup$ 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. $\endgroup$
    – dipetkov
    Dec 3, 2022 at 15:48
  • $\begingroup$ 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. $\endgroup$
    – dipetkov
    Dec 3, 2022 at 15:56

2 Answers 2


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.

  • $\begingroup$ Thanks a lot! Now it's much clearer!! $\endgroup$ 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.

  • $\begingroup$ Isn't the between school variability independent of the school type? $\endgroup$
    – dipetkov
    Dec 3, 2022 at 16:36
  • $\begingroup$ @dipetkov Yes. Some of the between school variability can be explained away by private school status. $\endgroup$ Dec 3, 2022 at 16:42
  • $\begingroup$ 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? $\endgroup$
    – dipetkov
    Dec 3, 2022 at 16:46
  • $\begingroup$ @dipetkov Private schools are a specific example. The same is true of all schools. $\endgroup$ Dec 3, 2022 at 17:00
  • 1
    $\begingroup$ @dipetkov I've added explicit reference to private and non-private schools in my answer for clarification $\endgroup$ Dec 3, 2022 at 17:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.