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

Estimating HLM Models Using Stata: Part 4

Estimating HLM Models Using Stata: Part 4

///
Comment0

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:

hlm21-104

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.

hlm24-105

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

hlm25-106

Equation 12 makes clear that modeling the slope is the same as including cross-level interactions. To include the interactions, first create new variables.

. gen sesXses = meanses*centnses
. gen sesXsect = sector*centnses

The syntax to estimate the model is the following:

. xtmixed mathach meanses sector centses sesXses sesXsect || id: centses , var cov(un)

The output is the following:


. xtmixed mathach meanses sector centses sesXses sesXsect || id: centses , var cov(un)

Performing EM optimization: 

Performing gradient-based optimization: 

Iteration 0:   log restricted-likelihood = -23252.886  
Iteration 1:   log restricted-likelihood = -23251.835  
Iteration 2:   log restricted-likelihood = -23251.832  
Iteration 3:   log restricted-likelihood = -23251.832  

Computing standard errors:

Mixed-effects REML regression                   Number of obs      =      7185
Group variable: id                              Number of groups   =       160

                                                Obs per group: min =        14
                                                               avg =      44.9
                                                               max =        67


                                                Wald chi2(5)       =    746.35
Log restricted-likelihood = -23251.832          Prob > chi2        =    0.0000

------------------------------------------------------------------------------
     mathach |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
     meanses |   5.332899   .3691582    14.45   0.000     4.609362    6.056436
      sector |   1.226453   .3062686     4.00   0.000     .6261772    1.826728
     centses |   2.938786    .155083    18.95   0.000     2.634829    3.242743
     sesXses |   1.038929   .2988835     3.48   0.001     .4531279     1.62473
    sesXsect |  -1.642622   .2397764    -6.85   0.000    -2.112575   -1.172669
       _cons |     12.096   .1987337    60.87   0.000     11.70649    12.48551
------------------------------------------------------------------------------

------------------------------------------------------------------------------
  Random-effects Parameters  |   Estimate   Std. Err.     [95% Conf. Interval]
-----------------------------+------------------------------------------------
id: Unstructured             |
                var(centses) |   .1011534   .2138601      .0016046    6.376825
                  var(_cons) |   2.379501   .3714475      1.752309     3.23118
          cov(centses,_cons) |    .191998   .2043357     -.2084926    .5924886
-----------------------------+------------------------------------------------
               var(Residual) |   36.72122   .6261423      35.51428    37.96917
------------------------------------------------------------------------------
LR test vs. linear regression:       chi2(3) =   220.56   Prob > chi2 = 0.0000

Note: LR test is conservative and provided only for reference.

These results correspond to Table 4.5 in R&B and the variance-covariance components on page 83.

Still have questions? Contact us!