This page is still under construction.
Let’s say we have measured children’s math test scores over 5 time points and these children are nested in multiple schools. We want to model the change of math test scores over time. Since measurements are nested in children and children are nested in schools, this leads to a three-level model. In Mplus, this can be done by modeling the five math test scores in multivariate fashion and modeling children nested in school in two-level model setting. On this page, we will show some examples. There is a mirroring page in Stata, where we follow the multilevel modeling tradition and all the modeling are performed using the same data set in long format. The data set can be downloaded following the link.
Model 1: Random-intercept model
In this example, we force the residual variance at each time point to be the same. By setting the variance of sw and sb at zero, we are modeling the slope of time and fixed effect.
Data: File is https://stats.idre.ucla.edu/wp-content/uploads/2016/02/growth_3l_wide.dat ; Variable: Names are cid math1 math2 math3 math4 math5 size lowinc mobility female black hispanic school; Missing are all (-9999) ; usevariables are math1 math2 math3 math4 math5; cluster is school; Analysis: Type = twolevel; model: %within% iw sw | math1@1 math2@2 math3@3 math4@4 math5@5; math1 - math5 (1); sw@0; %between% ib sb | math1@1 math2@2 math3@3 math4@4 math5@5; math1 - math5@0; sb@0;TESTS OF MODEL FIT Chi-Square Test of Model Fit Value 656.390* Degrees of Freedom 30 P-Value 0.0000 Scaling Correction Factor 1.074 for MLR * The chi-square value for MLM, MLMV, MLR, ULS, WLSM and WLSMV cannot be used for chi-square difference tests. MLM, MLR and WLSM chi-square difference testing is described in the Mplus Technical Appendices at www.statmodel.com. See chi-square difference testing in the index of the Mplus User's Guide. Chi-Square Test of Model Fit for the Baseline Model Value 1824.426 Degrees of Freedom 20 P-Value 0.0000 CFI/TLI CFI 0.653 TLI 0.769 Loglikelihood H0 Value -4195.466 H0 Scaling Correction Factor 2.958 for MLR H1 Value -3843.067 H1 Scaling Correction Factor 1.343 for MLR Information Criteria Number of Free Parameters 5 Akaike (AIC) 8400.932 Bayesian (BIC) 8423.849 Sample-Size Adjusted BIC 8407.972 (n* = (n + 2) / 24) RMSEA (Root Mean Square Error Of Approximation) Estimate 0.170 SRMR (Standardized Root Mean Square Residual) Value for Between 0.213 Value for Within 0.078 MODEL RESULTS Estimates S.E. Est./S.E. Std StdYX Within Level IW | MATH1 1.000 0.000 0.000 0.831 0.808 MATH2 1.000 0.000 0.000 0.831 0.808 MATH3 1.000 0.000 0.000 0.831 0.808 MATH4 1.000 0.000 0.000 0.831 0.808 MATH5 1.000 0.000 0.000 0.831 0.808 SW | MATH1 1.000 0.000 0.000 999.000 999.000 MATH2 2.000 0.000 0.000 999.000 999.000 MATH3 3.000 0.000 0.000 999.000 999.000 MATH4 4.000 0.000 0.000 999.000 999.000 MATH5 5.000 0.000 0.000 999.000 999.000 Variances IW 0.691 0.037 18.869 1.000 1.000 SW 0.000 0.000 0.000 999.000 999.000 Residual Variances MATH1 0.367 0.020 18.212 0.367 0.347 MATH2 0.367 0.020 18.212 0.367 0.347 MATH3 0.367 0.020 18.212 0.367 0.347 MATH4 0.367 0.020 18.212 0.367 0.347 MATH5 0.367 0.020 18.212 0.367 0.347 Between Level IB | MATH1 1.000 0.000 0.000 0.413 1.000 MATH2 1.000 0.000 0.000 0.413 1.000 MATH3 1.000 0.000 0.000 0.413 1.000 MATH4 1.000 0.000 0.000 0.413 1.000 MATH5 1.000 0.000 0.000 0.413 1.000 SB | MATH1 1.000 0.000 0.000 999.000 999.000 MATH2 2.000 0.000 0.000 999.000 999.000 MATH3 3.000 0.000 0.000 999.000 999.000 MATH4 4.000 0.000 0.000 999.000 999.000 MATH5 5.000 0.000 0.000 999.000 999.000 Means IB -2.630 0.064 -41.115 -6.373 -6.373 SB 0.745 0.020 37.515 999.000 999.000 Intercepts MATH1 0.000 0.000 0.000 0.000 0.000 MATH2 0.000 0.000 0.000 0.000 0.000 MATH3 0.000 0.000 0.000 0.000 0.000 MATH4 0.000 0.000 0.000 0.000 0.000 MATH5 0.000 0.000 0.000 0.000 0.000 Variances IB 0.170 0.049 3.498 1.000 1.000 SB 0.000 0.000 0.000 999.000 999.000 Residual Variances MATH1 0.000 0.000 0.000 0.000 0.001 MATH2 0.000 0.000 0.000 0.000 0.001 MATH3 0.000 0.000 0.000 0.000 0.001 MATH4 0.000 0.000 0.000 0.000 0.001 MATH5 0.000 0.000 0.000 0.000 0.001 R-SQUARE Within Level Observed Variable R-Square MATH1 0.653 MATH2 0.653 MATH3 0.653 MATH4 0.653 MATH5 0.653
Model 2: Random-intercept and random slope model at both children’s level and school’s level
Data: File is https://stats.idre.ucla.edu/wp-content/uploads/2016/02/growth_3l_wide.dat ; Variable: Names are cid math1 math2 math3 math4 math5 size lowinc mobility female black hispanic school; Missing are all (-9999) ; usevariables are math1 math2 math3 math4 math5; cluster is school; Analysis: Type = twolevel; model: %within% iw sw | math1@1 math2@2 math3@3 math4@4 math5@5; math1 - math5 (1); %between% ib sb | math1@1 math2@2 math3@3 math4@4 math5@5; math1 - math5@0;TESTS OF MODEL FIT Chi-Square Test of Model Fit Value 330.344* Degrees of Freedom 26 P-Value 0.0000 Scaling Correction Factor 1.344 for MLR * The chi-square value for MLM, MLMV, MLR, ULS, WLSM and WLSMV cannot be used for chi-square difference tests. MLM, MLR and WLSM chi-square difference testing is described in the Mplus Technical Appendices at www.statmodel.com. See chi-square difference testing in the index of the Mplus User's Guide. Chi-Square Test of Model Fit for the Baseline Model Value 1824.426 Degrees of Freedom 20 P-Value 0.0000 CFI/TLI CFI 0.831 TLI 0.870 Loglikelihood H0 Value -4065.104 H0 Scaling Correction Factor 1.339 for MLR H1 Value -3843.067 H1 Scaling Correction Factor 1.343 for MLR Information Criteria Number of Free Parameters 9 Akaike (AIC) 8148.207 Bayesian (BIC) 8189.458 Sample-Size Adjusted BIC 8160.880 (n* = (n + 2) / 24) RMSEA (Root Mean Square Error Of Approximation) Estimate 0.127 SRMR (Standardized Root Mean Square Residual) Value for Between 0.109 Value for Within 0.047 MODEL RESULTS Estimates S.E. Est./S.E. Within Level IW | MATH1 1.000 0.000 0.000 MATH2 1.000 0.000 0.000 MATH3 1.000 0.000 0.000 MATH4 1.000 0.000 0.000 MATH5 1.000 0.000 0.000 SW | MATH1 1.000 0.000 0.000 MATH2 2.000 0.000 0.000 MATH3 3.000 0.000 0.000 MATH4 4.000 0.000 0.000 MATH5 5.000 0.000 0.000 SW WITH IW 0.014 0.009 1.470 Variances IW 0.511 0.056 9.054 SW 0.012 0.003 3.580 Residual Variances MATH1 0.308 0.016 19.337 MATH2 0.308 0.016 19.337 MATH3 0.308 0.016 19.337 MATH4 0.308 0.016 19.337 MATH5 0.308 0.016 19.337 Between Level IB | MATH1 1.000 0.000 0.000 MATH2 1.000 0.000 0.000 MATH3 1.000 0.000 0.000 MATH4 1.000 0.000 0.000 MATH5 1.000 0.000 0.000 SB | MATH1 1.000 0.000 0.000 MATH2 2.000 0.000 0.000 MATH3 3.000 0.000 0.000 MATH4 4.000 0.000 0.000 MATH5 5.000 0.000 0.000 SB WITH IB -0.012 0.010 -1.198 Means IB -2.633 0.071 -37.265 SB 0.746 0.020 37.862 Intercepts MATH1 0.000 0.000 0.000 MATH2 0.000 0.000 0.000 MATH3 0.000 0.000 0.000 MATH4 0.000 0.000 0.000 MATH5 0.000 0.000 0.000 Variances IB 0.134 0.031 4.302 SB 0.012 0.003 3.892 Residual Variances MATH1 0.000 0.000 0.000 MATH2 0.000 0.000 0.000 MATH3 0.000 0.000 0.000 MATH4 0.000 0.000 0.000 MATH5 0.000 0.000 0.000