Title: | R-Squared with Multiply Imputed Data |
---|---|
Description: | Provides R-squared values and standardized regression coefficients for linear models applied to multiply imputed datasets as obtained by 'mice'. Confidence intervals, zero-order correlations, and alternative adjusted R-squared estimates are also available. The methods are described in Van Ginkel and Karch (2024) <doi:10.1111/bmsp.12344> and in Van Ginkel (2020) <doi:10.1007/s11336-020-09696-4>. |
Authors: | Julian D. Karch [aut, cph, cre] , Joost van Ginkel [aut, cph] |
Maintainer: | Julian D. Karch <[email protected]> |
License: | AGPL (>= 3) |
Version: | 0.2.0 |
Built: | 2024-12-05 18:35:49 UTC |
Source: | CRAN |
This function calculates the R-squared value for a linear model applied to a multiply imputed dataset, along with standardized regression coefficients. Optionally, it can also return the confidence intervals of the standardized regression coefficients and the zero-order correlations.
RsquareSP( object, cor = FALSE, conf = FALSE, conf.level = 0.95, alternative_adj_R2 = FALSE )
RsquareSP( object, cor = FALSE, conf = FALSE, conf.level = 0.95, alternative_adj_R2 = FALSE )
object |
The results of a regression on a multiply imputed dataset of class 'mira' from the 'mice' package. |
cor |
Logical. If 'TRUE', the function returns the zero-order correlations between the outcome and each predictor. |
conf |
Logical. If 'TRUE', the function returns the confidence intervals of the standardized regression coefficients. |
conf.level |
A real number between 0 and 1 specifying the confidence level of the confidence intervals. |
alternative_adj_R2 |
Logical. If 'TRUE', the function returns alternative estimates of adjusted R^2, as described in the references |
The function first completes the imputed datasets using 'mice::complete'. It then calculates the linear model on each imputed dataset and averages the standardized coefficients and correlations across imputations. The final R-squared value is computed as the sum of the products of the averaged standardized coefficients and averaged correlations. The confidence intervals of the standardized regression coefficients are calculated under the assumption that the variables are multivarate normally distributed
A list of class 'RsquaredMI' containing the following elements:
r_squared |
The R-squared value calculated using standardized predictors. |
r |
The square root of the R-squared value, or the multiple correlation R. |
rtotal |
A vector containing both the R-squared and R. |
beta |
The standardized regression coefficients. |
lower |
The lowerbound of the condidence intervals of the standardized regression coefficients (if 'conf = TRUE'). |
upper |
The upperbound of the condidence intervals of the standardized regression coefficients (if 'conf = TRUE'). |
dfe |
The error degrees of freedom of the condidence intervals of the standardized regression coefficients (if 'conf = TRUE'). |
zero |
The zero-order correlations between the outcome and each predictor |
total |
A matrix containing the betas and optionally (if 'cor = TRUE'), the error degrees of freedom, confidence intervals, and zero-order correlations. |
Van Ginkel, J.R., & Karch, J.D. (2024). A comparison of different measures of the proportion of explained variance in multiply imputed data sets. British Journal of Mathematical and Statistical Psychology. doi:10.1111/bmsp.12344
Karch, J.D. (2024). Improving on Adjusted R-squared. Collabra: Psychology. doi:10.1525/collabra.343
Van Ginkel, J.R. (2020). Standardized regression coefficients and newly proposed estimators for R^2 in multiply imputed data. Psychometrika. doi:10.1007/s11336-020-09696-4
library(mice) imp <- mice(nhanes, print = FALSE, seed = 16117) fit <- with(imp, lm(chl ~ age + hyp + bmi)) RsquareSP(fit)
library(mice) imp <- mice(nhanes, print = FALSE, seed = 16117) fit <- with(imp, lm(chl ~ age + hyp + bmi)) RsquareSP(fit)