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.
 A: 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.
A: 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.
