r2_mlm: A command for computing R-squared measures for models fit by mixed
The article by Rights and Sterba (2023, Multivariate Behavioral Research 58: 340-367) provides a comprehensive framework for computing <mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML" display="inline" overflow="scroll"> <mml:msup> <mml:mi>R</mml:mi> <mml:mn>2</mml:mn> </mml:msup> </mml:math> measures for (linear) multilevel models. In this article, we introduce r2_mlm , a postestimation command for mixed that computes <mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML" display="inline" overflow="scroll"> <mml:msup> <mml:mi>R</mml:mi> <mml:mn>2</mml:mn> </mml:msup> </mml:math> measures using Rights and Sterba’s framework. We explain how this <mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML" display="inline" overflow="scroll"> <mml:msup> <mml:mi>R</mml:mi> <mml:mn>2</mml:mn> </mml:msup> </mml:math> framework works and demonstrate how r2_mlm can be used to compute various <mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML" display="inline" overflow="scroll"> <mml:msup> <mml:mi>R</mml:mi> <mml:mn>2</mml:mn> </mml:msup> </mml:math> measures for models fit by mixed . One of the most useful features of r2_mlm is that it will produce warning messages if the user specifies the model in a way that may lead to conflation bias (an easily overlooked issue). Finally, we walk through a simple example and explain how to interpret the various <mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML" display="inline" overflow="scroll"> <mml:msup> <mml:mi>R</mml:mi> <mml:mn>2</mml:mn> </mml:msup> </mml:math> measures.
Authors
- D. Betsy McCoach (ORCID: https://orcid.org/0000-0001-9063-6835)
- Anthony J. Gambino (ORCID: https://orcid.org/0000-0001-5820-1997)
Institutions
- University of Connecticut (US)
- Fordham University (US)
Publication Details
- Journal
- The Stata Journal Promoting communications on statistics and Stata
- Published
- 2025-12-01
- DOI
- https://doi.org/10.1177/1536867x251398326
- Primary Topic
- Psychometric Methodologies and Testing
- Type
- article
- Field-Weighted Citation Impact
- 0.00