# Estimating HLM Models Using Stata: Part 2

## The Means-as-Outcomes Model

After estimating the empty model, R&B develop a Means-as-Outcomes model in which a school-level variable, meanses, is added to the model for the intercept. This variable reflects the average student SES level in each school. Recall that, when fitting the empty model, we began with the following equation:

\[ Y_{ij} = \beta_{0j} + e_{ij} \]

Now the intercept can be modeled as a grand mean, \(\gamma_{00}\), plus the effect of the average SES score, \(\gamma_{01}\), plus a random error, \(u_{0j}\).

\[ \beta_{0j} = \gamma_{00} + \gamma_{01}(\text{Mean SES}_j) + u_{0j} \]

Substituting,

\[ Y_{ij} = \gamma_{00} + \gamma_{01}(\text{Mean SES}_j) + u_{0j} + e_{ij} \]

The following will estimate the model.

`mixed mathach meanses || schid: , reml`

```
Performing EM optimization:
Performing gradient-based optimization:
Iteration 0: log restricted-likelihood = -23480.642
Iteration 1: log restricted-likelihood = -23480.642
Computing standard errors:
Mixed-effects REML regression Number of obs = 7,185
Group variable: schid Number of groups = 160
Obs per group:
min = 14
avg = 44.9
max = 67
Wald chi2(1) = 263.15
Log restricted-likelihood = -23480.642 Prob > chi2 = 0.0000
------------------------------------------------------------------------------
mathach | Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
meanses | 5.863538 .3614574 16.22 0.000 5.155095 6.571982
_cons | 12.64944 .1492799 84.74 0.000 12.35685 12.94202
------------------------------------------------------------------------------
------------------------------------------------------------------------------
Random-effects Parameters | Estimate Std. Err. [95% Conf. Interval]
-----------------------------+------------------------------------------------
schid: Identity |
var(_cons) | 2.638696 .404337 1.954144 3.563051
-----------------------------+------------------------------------------------
var(Residual) | 39.15709 .6608017 37.88312 40.47389
------------------------------------------------------------------------------
LR test vs. linear model: chibar2(01) = 239.95 Prob >= chibar2 = 0.0000
```

The only difference from the empty model is that we’ve now included `meanses`

as a fixed effect. The estimate of 5.864 tells us how much on average across all schools we would expect math achievement to increase for each unit increase in the school-level mean SES. This effect is statistically significant, \(p < 0.001\).

The next step is to fit a random coefficient model.