# Mixed effects model with level 2 explanatory variable [duplicate]

Take this linear mixed effects model, which is discussed on the CMM website: Centre for Multilevel Modelling

$y_{ij} = \beta_0 + \beta_1X_{ij} + \beta_2\bar{X}_j + u_j + e_{ij}$

The variable $X$ is included as both a level 1 and level 2 explanatory variable. The value of $X$ is included for each person $i$ in each group $j$ and it is also included as the mean for each group $j$.

But if $X$ is included as the mean for each group $j$, why would it be necessary to include a random intercept for each group $j$ as well?

## marked as duplicate by Firebug, COOLSerdash, John, Peter Flom♦May 9 '17 at 10:52

The inclusion of random intercepts for groups $j$ would appear to be necessary because differences in $\bar{X}_j$ doesn't necessarily explain differences among groups $j$. The inclusion $\bar{X}_j$ can be used to test hypotheses that differences among groups $j$ is due to differences among $\bar{X}_j$.