# Better understanding of "within" and "between" in multilevel models

In my work I mostly use latent variable modeling, but due to a recent project, I now have to also use a multilevel model. I have a situation where latent constructs of geography knowledge (measured with 20 test items) and learning motivation (measured with 10 questionnaire items) are measured for every pupil. Pupils are nested within schools.

For simplicity purposes, let's assume that the latent variable scores are already precalculated. Then the model consists of a regression equation:

$$G_{i} = \beta_{0i} + \beta_{1i}M + \epsilon_{i}$$,

where $$G$$ is geography knowledge, $$M$$ is learning motivation, $$\beta_{0i}$$ is the intercept of school $$i$$ and $$\beta_{1i}$$ is the slope, and $$\epsilon_{i}$$ is the residual.

Firstly I would just like to confirm I got this right?

Secondly, I am moving on to some software that requires me to specify the within- and between- parts of the model, and here I reach the part which I don't understand. To my understanding, the within part of the model is the part written above in the equation. The between part of the model would exist if I measured some school-level variables (e.g. school budget, do they employ psychologists etc.) and if these variables were related to some external variables or to the within-level variables.

I have no school-level variables in the model. To my understanding, this would mean that I have no between- part in my model. However, I've read on some online forums (namely, the Mplus forum), that if you have nothing in the between part of the model, then your model is not a multilevel model, but just a simple regression.

Therefore I am now confused and I would appreciate if someone could clear this up. To make it as simple as possible, the questions would be:

Does my model have a between part, or does it only have a within part? If it has a between part, how does it look like?

## 2 Answers

In addition to @Christian Geiser's excellent answer, it can be helpful to write out the model in the two-stage form, which shows equations for the within and between parts of the model.

##### Level 1 (within schools):

$$geo_{ij} = B_{0j} + B_{1j}*X(motiv)_{ij} + e_{ij}$$

##### Level 2 (between schools):

$$B_{0j} = \gamma_{00} + u_{0j}$$

$$B_{1j} = \gamma_{10} + u_{1j}$$

As Christian said, at the between level, you have two means, one for the population intercept ($$\gamma_{00}$$) and one for the population slope ($$\gamma_{10}$$). We typically assume that the residuals/disturbances at the between level have a bivariate normal distribution with zero mean and covariance matrix, $$T$$, such that,

$$T =\begin{bmatrix} \tau_{00} & \tau_{01} \\ \tau_{10} & \tau_{11} \end{bmatrix}, \tau_{10}=\tau_{01}$$

If instead of MPlus, you were using a mixed effects modeling approach as in the lmer() function in R's lme4 package, the model would be specified as follows:

m1 <- lmer(geo ~ 1 + motiv + (1 + motiv | school_id), data = dat)


With this formulation, lmer gives you an unstructured random effects covariance matrix as above.

What you have is often referred to as a "random coefficient regression." See, e.g., the reference below. The intercept and slope of the level 1 (within-level) regression are called "random coefficients" because they are allowed to vary across level-2 units (schools). Since there are no between (school) level predictors in your model, the level-2 (between) part of your model only consists of the mean intercept and slope, the variance of the intercept and slope, and (potentially) the covariance between the intercept and slope as freely estimated parameters. Only the covariance between intercept and slope would have to be explicitly specified in Mplus. The intercept and slope means and variances are estimated by default in Mplus. Below is an example syntax:

model: %within%
beta1i | G on M; ! random coefficient regression

%between%
G with M; ! covariance of random intercept and slope


Reference:

Luke, D. A. (2004). Multilevel modeling. Thousand Oaks: Sage.