Skip to Main Content

Annotated Mplus Output: Two Level Multilevel Model, Example 1

This page shows an example of a two level multilevel model.  First a multilevel model is shown using HLM and then using
Stata, and then the same data are analyzed using Mplus using a multilevel model.
The Mplus
output is related to the multilevel model results. We suggest that
you view this page using two web browsers so you can show the page side by side
showing the Stata output in one browser and the corresponding Mplus output in
the other browser.

This example is drawn from the Mplus User’s Guide (example 6.1) and we suggest that
you see the Mplus User’s Guide for more details about this example. We thank the
kind people at Muthén & Muthén for permission to use examples from their manual.

Example Using HLM

Each subject is observed on the variable Y at four different times.
Conceptualized as a multilevel model, the variable time is a level 1
variable. Time is coded 0, 1, 2, and 3. The intercept is the predicted value
when time is 0. Each subject has their own intercept and slope,
expressed as random effects at level 2. We can
write this model using multiple equations as shown below. This uses the ex61.mdm file.

$$
\begin{eqnarray}
\mbox{Level 1:} \quad Y_{ij} & = & \beta_{0j} + \beta_{1j} Time + r_{ij} \\
\mbox{Level 2:} \quad \beta_{0j} & = & \gamma_{00} + u_{0j} \\
\beta_{1j} & = & \gamma_{10} + u_{1j}
\end{eqnarray}
$$

Here is the output from HLM, condensed to save space. Footnotes are included
for relating the output to Mplus.

Summary of the model specified (in equation format)
---------------------------------------------------

Level-1 Model

	Y = B0 + B1*(TIME) + R

Level-2 Model
	B0 = G00 + U0
	B1 = G10 + U1

Iterations stopped due to small change in likelihood function
******* ITERATION 2 *******

 Sigma_squared =      0.48774F

 Tau
 INTRCPT1,B0      0.98667C      0.13242 
     TIME,B1      0.13242E      0.22750D

Tau (as correlations)
 INTRCPT1,B0  1.000  0.279
     TIME,B1  0.279  1.000

Final estimation of fixed effects:
----------------------------------------------------------------------------
                                      Standard             Approx.
   Fixed Effect         Coefficient   Error      T-ratio   d.f.     P-value
----------------------------------------------------------------------------
For       INTRCPT1, B0
   INTRCPT2, G00           0.522793A  0.051538    10.144       499    0.000
For     TIME slope, B1
   INTRCPT2, G10           1.026268B  0.025497    40.250       499    0.000
----------------------------------------------------------------------------

Example Using Stata

Combining the two equations into one by substituting the level 2 equation
into the level 1 equation, we have the equation below, with the random effects
identified by placing them in square brackets.

$$
MathAch_{ij} = \gamma_{00} + \gamma_{10}(MeanSES) + [ u_{0j} + r_{ij}] $$

Here is an example using Stata.

infile y0 y1 y2 y3 using https://stats.idre.ucla.edu/stat/mplus/output/ex6.1.dat, clear
generate id = _n
reshape long y, i(id) j(time)
mixed y time || id: time, cov(un)
Mixed-effects ML regression                     Number of obs      =      2000
Group variable: id                              Number of groups   =       500

                                                Obs per group: min =         4
                                                               avg =       4.0
                                                               max =         4


                                                Wald chi2(1)       =   1623.34
Log likelihood = -3016.6973                     Prob > chi2        =    0.0000

------------------------------------------------------------------------------
           y |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
        time |   1.026268B  .0254715    40.29   0.000     .9763442    1.076191
       _cons |    .522793A  .0514865    10.15   0.000     .4218814    .6237047
------------------------------------------------------------------------------

------------------------------------------------------------------------------
  Random-effects Parameters  |   Estimate   Std. Err.     [95% Conf. Interval]
-----------------------------+------------------------------------------------
id: Unstructured             |
                   var(time) |   .2268527D  .0209755      .1892514    .2719247
                  var(_cons) |   .9840141C  .0852067      .8304146    1.166025
             cov(time,_cons) |   .1324435E  .0300523      .0735421     .191345
-----------------------------+------------------------------------------------
               var(Residual) |   .4877361F  .0218122       .446805    .5324169
------------------------------------------------------------------------------
LR test vs. linear regression:       chi2(3) =  1601.32   Prob > chi2 = 0.0000
Note: LR test is conservative and provided only for reference

Mplus Example

Here is the same example analyzed as a multilevel model using Mplus based on the
ex61l.dat data file.

Title:
  Multilevel model
Data:
  File is ex61l.dat ;
Variable:
  Names are
  id time y;
  WITHIN = time ;
  CLUSTER = id;
ANALYSIS:
  TYPE = TWOLEVEL RANDOM;
MODEL:
  %WITHIN%
    s | y ON time;
  %BETWEEN%
    y s ;
    y with s;

SUMMARY OF ANALYSIS
Number of observations                                        2000

SUMMARY OF DATA
     Number of clusters         500

     Average cluster size   4.000

     Estimated Intraclass Correlations for the Y Variables

                Intraclass              Intraclass
     Variable  Correlation   Variable  Correlation

     Y            0.452

TESTS OF MODEL FIT

Loglikelihood
          H0 Value                       -3016.699

Information Criteria
          Number of Free Parameters              6
          Akaike (AIC)                    6045.397
          Bayesian (BIC)                  6079.003
          Sample-Size Adjusted BIC        6059.940
            (n* = (n + 2) / 24)

MODEL RESULTS
                   Estimates     S.E.  Est./S.E.

Within Level
 Residual Variances
    Y                  0.487F   0.024     20.455

Between Level
 Y        WITH
    S                  0.131E   0.032      4.078

 Means
    Y                  0.523A   0.051     10.154
    S                  1.026B   0.025     40.291

 Variances
    Y                  0.986C   0.081     12.130
    S                  0.227D   0.020     11.262
  1. This is γ00 in the multilevel model. It is the predicted value of  y when time is 0.
  2. This is γ10 in the multilevel model. It is the predicted value increase in y for a one unit increase in time.
  3. This is the variance of the intercept, the variance of u0j in the multilevel model.
  4. This is the variance of the slope, the variance of u1j in the multilevel model.
  5. This is the covariance of the intercept and slope, the covariance β0j and β1j from the multilevel model.
  6. This is the residual variance at level 1.

Go back to Annotated Output page on Latent Growth and Multilevel Models in Mplus