Mon - Fri : 08:00 AM - 5:00 PM
734.544-8038

# Estimating HLM Models Using R: Part 4

### Note: For a fuller treatment, download our series of lectures Hierarchical Linear Models.

#### Intercepts- and Slopes-as-Outcomes Model

R&B present a final model that includes one further generalization of the random coefficients model. They begin again with the level-1 model:

$$\tag{6} Y_{ij} = \beta_{0j} + \beta_{1j}(SES) + e_{ij}$$

The intercept β0j is now modeled as a function of the average SES level of the school and whether or not the school is public or private. The slope β1j is modeled in a similar fashion.

$$\tag{10} \beta_{0j} = \gamma_{00} + \gamma_{01}(MEAN \; SES) + \gamma_{02}(SECTOR) + u_{0j}$$

$$\tag{11} \beta_{1j} = \gamma_{10} + \gamma_{11}(MEAN \; SES) + \gamma_{12}(SECTOR) + u_{1j}$$

Substituting (10) and (11) into (6) leads to the combined model:

$$\tag{12} Y_{ij} = \gamma_{00} + \gamma_{01}(MEAN \; SES) + \gamma_{02}(SECTOR) + \gamma_{10}(SES) + \\ \qquad \gamma_{11}(MEAN \; SES)(SES) + \gamma_{12}(SECTOR)(SES) + u_{0j} + \\ u_{1j}(SES) + e_{ij}$$

Equation 12 makes clear that modeling the slope is the same as including cross-level interactions. R allows interactions to be entered into a model statement easily and efficiently, as the following syntax demonstrates.

> model4<-lme(mathach ~ meanses*cent.ses + sector*cent.ses, random = ~ cent.ses | id, data=hsb)

Alternatively,

> model4<-update(model3, mathach ~ meanses*cent.ses + sector*cent.ses)

It is only necessary to specify interactions with one multiplicative term; R will automatically estimate both main effects and the interaction. The output corresponding to this model is the following.


> summary(model4)
Linear mixed-effects model fit by REML
Data: hsb
AIC      BIC    logLik
46523.66 46592.45 -23251.83

Random effects:
Formula: ~cent.ses | id
Structure: General positive-definite, Log-Cholesky parametrization
StdDev    Corr
(Intercept) 1.5425961 (Intr)
cent.ses    0.3180665 0.391
Residual    6.0598009

Fixed effects: mathach ~ meanses * cent.ses + sector * cent.ses
Value Std.Error   DF  t-value p-value
(Intercept)      12.095997 0.1987367 7022 60.86444   0e+00
meanses           5.332900 0.3691639  157 14.44589   0e+00
cent.ses          2.938787 0.1550835 7022 18.94971   0e+00
sector            1.226453 0.3062734  157  4.00444   1e-04
meanses:cent.ses  1.038929 0.2988844 7022  3.47602   5e-04
cent.ses:sector  -1.642623 0.2397771 7022 -6.85062   0e+00
Correlation:
(Intr) meanss cnt.ss sector mnss:.
meanses           0.245
cent.ses          0.075  0.019
sector           -0.697 -0.356 -0.053
meanses:cent.ses  0.018  0.074  0.282 -0.026
cent.ses:sector  -0.052 -0.027 -0.694  0.077 -0.351

Standardized Within-Group Residuals:
Min          Q1         Med          Q3         Max
-3.15919697 -0.72318616  0.01706253  0.75436438  2.95817852

Number of Observations: 7185
Number of Groups: 160

> VarCorr(model4)
id = pdLogChol(cent.ses)
Variance   StdDev    Corr
(Intercept)  2.3796028 1.5425961 (Intr)
cent.ses     0.1011663 0.3180665 0.391
Residual    36.7211874 6.0598009



These results correspond (with some slight differences) to Table 4.5 in R&B and the variance-covariance components on page 83.