# Computes R Squared for Mixed (Multilevel) Models

The model R squared and semi-partial R squared for the linear and generalized linear mixed model (LMM and GLMM) are computed with confidence limits. The R squared measure from Edwards et.al (2008) is extended to the GLMM using penalized quasi-likelihood (PQL) estimation (see Jaeger et al. 2016 ). Three methods of computation are provided and described as follows. First, The Kenward-Roger approach. Due to some inconsistency between the 'pbkrtest' package and the 'glmmPQL' function, the Kenward-Roger approach in the 'r2glmm' package is limited to the LMM. Second, The method introduced by Nakagawa and Schielzeth (2013) and later extended by Johnson (2014) . The 'r2glmm' package only computes marginal R squared for the LMM and does not generalize the statistic to the GLMM; however, confidence limits and semi-partial R squared for fixed effects are useful additions. Lastly, an approach using standardized generalized variance (SGV) can be used for covariance model selection. Package installation instructions can be found in the readme file.

# r2glmm

This package computes model and semi partial R2 with confidence limits for the linear and generalized linear mixed model (LMM and GLMM). The R2 measure from Edwards et.al (2008) is extended to the GLMM using penalized quasi-likelihood (PQL) estimation (see Jaeger et al. 2016).

• Changes: Version 0.1.2
1. Optimized computation of matrix inverses and cross-products in order to decrease computation time.
• Changes: Version 0.1.1
1. Updated the r2beta function with an optional data argument. Users who wish to use a function (i.e. log(x)) in their model formula should specify the original data frame used by the model when using the r2beta function.
2. Included support for GLMMs fitted using the glmer function from the lme4 package.
3. Added generic plot and print functions for R2 objects.
• Why use this package?

The R2 statistic is a well known tool that describes goodness-of-fit for a statistical model. In the linear model, R2 is interpreted as the proportion of variance in the data explained by the fixed predictors and semi-partial R2 provide standardized measures of effect size for subsets of fixed predictors. In the linear mixed model, numerous definitions of R2 exist and interpretations vary by definition. The r2glmm package computes R2 using three definitions:

1. Rβ2, a standardized measure of multivariate association between the fixed predictors and the observed outcome. This method was introduced by Edwards et al. (2008)
2. RΣ2, the proportion of generalized variance explained by the fixed predictors. This method was introduced by Jaeger et al. (2017)
3. R(m)2, the proportion of variance explained by the fixed predictors. This method was introduced by Nakagawa and Schielzeth (2013) and later modified by Johnson (2014).

Each interpretation can be used for model selection and is helpful for summarizing model goodness-of-fit. While the information criteria are useful tools for model selection, they do not quantify goodness-of-fit, making the R2 statistic an excellent tool to accompany values of AIC and BIC. Additionally, in the context of mixed models, semi-partial R2 and confidence limits are two useful and exclusive features of the r2glmm package.

• Instructions for installation:

The most up-to-date version of the r2glmm package is available on Github. To download the package from Github, after installing and loading the devtools package, run the following code from the R console:

Alternatively, There is a version of the package available on CRAN. To download the package from CRAN, run the following code from the R console:

• How to use this package

The main function in this package is called r2beta. The r2beta function summarizes a mixed model by computing the model R2 statistic and semi-partial R2 statistics for each fixed predictor in the model. The r2glmm package computes R2 using three definitions. Below we list the methods, their interpretation, and an example of their application:

1. Rβ2, a standardized measure of multivariate association between the fixed predictors and the observed outcome. This statistic is primarily used to select fixed effects in the linear and generalized linear mixed model.
1. RΣ2, the proportion of generalized variance explained by the fixed predictors. This statistic is primarily used to select a covariance structure in the linear and generalized linear mixed model.
1. R(m)2, the proportion of variance explained by the fixed predictors. This statistic is a simplified version of Rβ2 that can be used as a substitute for models fitted to very large datasets.
• R2 for the Generalized Linear Mixed Model (GLMM)

The r2glmm package can compute Rβ2 for models fitted using the glmer function from the lme4 package. Note that this method is experimental in R and values of Rβ2 sometimes exceed 1. We recommend using the SAS macro available at https://github.com/bcjaeger/R2FixedEffectsGLMM/blob/master/Glimmix_R2_V3.sas. RΣ2 is more stable and can be computed for models fitted using either the glmer function or the glmmPQL function from the MASS package; however, minor differences in model estimation can lead to slight variation in the values of RΣ2.

# Reference manual

install.packages("r2glmm")

0.1.2 by Byron Jaeger, 2 years ago

https://github.com/bcjaeger/r2glmm

Report a bug at https://github.com/bcjaeger/r2glmm/issues

Browse source code at https://github.com/cran/r2glmm

Authors: Byron Jaeger [aut, cre]

Documentation:   PDF Manual