Estimating HLM Models Using Stata: Part 4
Intercepts- and Slopes-as-Outcomes
R&B present a final model that includes one further generalization of the random coefficients model. Start again with the level-1 model.
\[ Y_{ij} = \beta_{0j} + +\beta_{1j}(\text{SES}_{ij}) + e_{ij} \]
Next, model the intercept, \(\beta_{0j}\), as a function of school-level characteristics mean SES and school type (public or private).
\[ \begin{aligned} \beta_{0j} &= \gamma_{00} + \gamma_{01}(\text{Mean SES}_j) + \gamma_{02}(\text{School Type}_j) + u_{0j} \\ \beta_{1j} &= \gamma_{10} + \gamma_{11}(\text{Mean SES}_j) + \gamma_{12}(\text{School Type}_j) + u_{1j} \end{aligned} \]
Substituting:
\[ \begin{aligned} Y_{ij} = &\gamma_{00} +\gamma_{01}(\text{Mean SES}_j) + \gamma_{02}(\text{School Type}_j) + \gamma_{10}(\text{SES}_{ij}) + \\ &\gamma_{11}(\text{Mean SES}_j)(\text{SES}_{ij}) + \gamma_{12}(\text{School Type}_j)(\text{SES}_{ij}) + \\ &u_{0j} + u_{1j}(\text{SES}_{ij}) + e_{ij} \end{aligned} \]
where \(\text{SES}_{ij}\) is again group-mean centered. \((\text{Mean SES}_j)(\text{SES}_{ij})\) and \((\text{School Type}_j)(\text{SES}_{ij})\) represent cross-level interactions estimating how much the effect of student-level SES on math achievement varies by school-level SES and school type. Remaining between-school variability in the outcome is captured with the \(u_{0j}\) random effect, and remaining between-school variability in the effect of student-level SES is captured with the random effect \(u_{1j}\).
The following code fits the model.
mixed mathach meanses schtype grp_cent_ses c.meanses#c.grp_cent_ses i.schtype#c.grp_cent_ses \\\
|| schid: grp_cent_ses , reml cov(un)
Performing EM optimization:
Performing gradient-based optimization:
Iteration 0: log restricted-likelihood = -23252.888
Iteration 1: log restricted-likelihood = -23251.837
Iteration 2: log restricted-likelihood = -23251.834
Iteration 3: log restricted-likelihood = -23251.834
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(5) = 746.33
Log restricted-likelihood = -23251.834 Prob > chi2 = 0.0000
------------------------------------------------------------------------------------------
mathach | Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------------------+----------------------------------------------------------------
meanses | 5.339119 .3692995 14.46 0.000 4.615306 6.062933
schtype | 1.216672 .306386 3.97 0.000 .6161663 1.817177
grp_cent_ses | 2.938764 .155086 18.95 0.000 2.634801 3.242727
|
c.meanses#c.grp_cent_ses | 1.038884 .2988887 3.48 0.001 .4530734 1.624695
|
schtype#c.grp_cent_ses |
1 | -1.642587 .2397809 -6.85 0.000 -2.112549 -1.172625
|
_cons | 12.11358 .1988076 60.93 0.000 11.72393 12.50324
------------------------------------------------------------------------------------------
------------------------------------------------------------------------------
Random-effects Parameters | Estimate Std. Err. [95% Conf. Interval]
-----------------------------+------------------------------------------------
schid: Unstructured |
var(grp_ce~s) | .1012193 .2138705 .0016096 6.365067
var(_cons) | 2.38187 .3717503 1.75415 3.234218
cov(grp_ce~s,_cons) | .1925536 .2044904 -.2082403 .5933475
-----------------------------+------------------------------------------------
var(Residual) | 36.72119 .6261423 35.51425 37.96914
------------------------------------------------------------------------------
LR test vs. linear model: chi2(3) = 220.57 Prob > chi2 = 0.0000
Note: LR test is conservative and provided only for reference.
Note that the \(*\) operator in R automatically creates both the main effects and multiplicative terms for the interactions.