The coefficient of determination, denoted \(R^2\) and pronounced “R squared”, typically corresponds the proportion of the variance in the dependent variable (the response) that is explained (i.e., predicted) by the independent variables (the predictors).
It is an “absolute” index of goodness-of-fit, ranging from 0 to 1 (often expressed in percentage), and can be used for model performance assessment or models comparison.
As models become more complex, the computation of an \(R^2\) becomes increasingly less straightforward.
Currently, depending on the context of the regression model object, one can choose from the following measures supported in
TO BE COMPLETED.
In the context of a generalized linear model (e.g., a logistic model which outcome is binary), \(R^2\) doesn’t measure the percentage of “explained variance”, as this concept doesn’t apply. However, the \(R^2\)s that have been adapted for GLMs have retained the name of “R2”, mostly because of the similar properties (the range, the sensitivity, and the interpretation as the amount of explanatory power).
For mixed models,
performance will return two different \(R^2\)s:
The marginal \(R^2\) considers only the variance of the fixed effects (without the random effects), while the conditional \(R^2\) takes both the fixed and random effects into account (i.e., the total model).
> # R2 for Mixed Models > > Conditional R2: 0.933 > Marginal R2: 0.303
r2 functions only return the \(R^2\) values. We would encourage users to instead always use the
compare_performance function to get a more comprehensive set of indices of model fit.
> # Indices of model performance > > AIC | BIC | R2 (cond.) | R2 (marg.) | ICC | RMSE | Sigma > ------------------------------------------------------------------- > 159.036 | 171.079 | 0.933 | 0.303 | 0.904 | 0.373 | 0.378
But, in the current vignette, we would like to exclusively focus on this family of functions and will only talk about this measure.
> # Bayesian R2 with Standard Error > > Conditional R2: 0.816 (89% CI [0.735, 0.887])
As discussed above, for mixed-effects models, there will be two components associated with \(R^2\).
> # Bayesian R2 with Standard Error > > Conditional R2: 0.953 (89% CI [0.944, 0.962]) > Marginal R2: 0.826 (89% CI [0.747, 0.889])
If you want to know more about these indices, you can check out details and references in the functions that compute them here.
If you want to know about how to interpret these \(R^2\) values, see these interpretation guidelines.