What to do
- Fit the model with
SAMPSTATin the OUTPUT command. - Drop the
.outfile on the box below. - Read what the page found before reading the measures: the sources of the variance are only as good as the quantities they were built from, and the page names every one of them.
.out file here, or press Enter to choose one.
The file is read in your browser and is not sent anywhere.
What was read
The list appears here once an output file has been read.
The partition of the variance
The partition appears here once an output file has been read.
The twelve measures
The measures appear here once an output file has been read.
Methods and formulas
Why one model is enough
Earlier multilevel R² measures compare variance components from an empty model and a fitted model. LaHuis et al. (2014) found that subtraction-based measures can be negative and that some level-2 versions showed substantial bias in their simulations. The single-model variance-partition approach used here avoids negative explained-variance components by construction and performed comparatively well with random slopes, at the cost of more calculation.
The partition
The predictors of the first level are the ones that vary within a cluster and the predictors of the second level the ones that vary between clusters, which is the within level and the between level of the model as Mplus prints it. Writing a two-level model with level-1 predictors xw centered on their cluster means, level-2 predictors xb, and the subset w of the level-1 predictors whose slopes vary between clusters, the variance the model implies for the outcome is the sum of five terms (Rights & Sterba, 2019, Eq. 10):
Here and are the fixed effects of the level-1 and level-2 predictors, and the covariance matrices of those predictors, T the covariance matrix of the random slopes, Σ the covariance matrix of the predictors those slopes belong to, the variance of the random intercept and the level-1 residual variance. The five terms are, in order (Eq. 11 to 15), the variance attributable to the level-1 predictors through their fixed slopes, to the level-2 predictors through their fixed slopes, to the level-1 predictors through the variation and covariation of their slopes, to the cluster-specific means through the variation of the intercept, and to the level-1 residuals.
Three of the five belong entirely to the variation within clusters, so the within-cluster variance the model implies is their sum (Eq. 16), and the remaining two make up the between-cluster variance (Eq. 17):
The twelve measures
Each R² measure pairs a source of explained variance with a denominator (Rights & Sterba, 2019, Table 1). Subscripts t, w and b denote total, within-cluster and between-cluster outcome variance. Superscripts f1, f2, v and m denote level-1 fixed effects, level-2 fixed effects, random-slope variation and random-intercept variation; combined superscripts sum the corresponding sources. The two between-cluster measures isolate f2 and m, whose shares sum to one at that level.
The seven total measures are not alternatives to one another and are not meant to be reported one at a time. Rights and Sterba recommend giving the four that each carry a single source, , , and , together with their level-specific counterparts, and reading them against the picture of the whole partition rather than in isolation. The bar chart above is that picture, in the form of their Figure 1.
Where each quantity comes from
The fixed effects, the random slope covariances, the intercept variance and the residual variance are parameters of the model and are read from MODEL RESULTS: the level-1 fixed slope of a predictor whose slope is random is the mean of that slope at the between level, which is where Mplus puts it when the slope is defined with s | y ON x;. The covariance matrices of the predictors are not parameters of the model when the predictors are exogenous and observed, which is the usual case: the model conditions on them. They are read instead from the estimated sample statistics of the two levels, which SAMPSTAT prints, and from MODEL RESULTS when the model does estimate them. The table above names the source of every one of them, and when one is missing the page says which predictor it belongs to and computes nothing, rather than filling the gap.
Two conditions are checked rather than assumed. The Table 1 measures are defined for level-1 predictors centered on their cluster means, so the page verifies that every level-1 predictor it is about to use appears under GROUPMEAN centering in the echoed input. Finding the word GROUPMEAN somewhere is not enough. If even one predictor is not verified, the Table 1 partition is not computed; a non-centered model requires the different formulas in Rights and Sterba's Table 5. The sum of the five terms is also compared with the variance of the outcome in the sample statistics: a large discrepancy means that some source of variance in the model was not read, and the page reports the discrepancy so that the measures are not taken for a complete partition when they are not one.
Self-test
Append ?selftest=1 to check two-level parsing, variance components, quadratic forms, trace calculations, level-specific partitions, combined measures, and unsupported inputs.
References
- LaHuis, D. M., Hartman, M. J., Hakoyama, S., & Clark, P. C. (2014). Explained variance measures for multilevel models. Organizational Research Methods, 17(4), 433–451. https://doi.org/10.1177/1094428114541701
- Rights, J. D., & Sterba, S. K. (2019). Quantifying explained variance in multilevel models: An integrative framework for defining R-squared measures. Psychological Methods, 24(3), 309–338. https://doi.org/10.1037/met0000184
- Snijders, T. A. B., & Bosker, R. J. (2012). Multilevel analysis: An introduction to basic and advanced multilevel modeling (2nd ed.). Sage.