# Mixed effects model for nested data

I'm facing a problem similar to the following.

There are 8 schools and each one contains a certain number of students. For each student I have a set of continuous variable (one of which is the dependent variable Y while the other are covariates). In addition, each student was assigned one of 4 possible interventions. My goal is to study the effect of the 4 different interventions on Y keeping into account the nested structure of the data.

If the interventions were randomly assigned to the students I would have used a mixed effects linear regression using the grouping variable "school" as a random effect (imagine a model with only the random intercept for simplicity), and intervention and other patient level covariates as fixed effects.

My problem is that the four interventions are randomly assigned at the school level: the interventions are applied to individual students, but students from the same school undergo the same intervention. So I have students nested within 8 schools nested within 4 interventions (2 schools per intervention).

Can I still calculate the effect of intervention on Y (treating it as a fixed effect) accounting for the effect of the school? Which model would you use?

Y ~ intervention + covariates + (1 | schoolID)