I have a linear model with multiple predictor variables, and I would like to know the partial R2 values for each predictor. I see the partial p-values in the summary
output but not the partial R2s. Do i need to download additional packages for this?
df <- mtcars
mod.mlr <-summary( lm(mpg ~., data = df))
You can use the function partial_r2
of the R package sensemakr to compute the partial R2.
library(sensemakr)
#> See details in:
#> Carlos Cinelli and Chad Hazlett (2020). Making Sense of Sensitivity: Extending Omitted Variable Bias. Journal of the Royal Statistical Society, Series B (Statistical Methodology).
df <- mtcars
model <- lm(mpg ~., data = df)
partial_r2(model)
#> (Intercept) cyl disp hp drat wt
#> 0.0201591032 0.0005412271 0.0258677677 0.0443187825 0.0109107458 0.1548024114
#> qsec vs am gear carb
#> 0.0566909597 0.0010844617 0.0667336071 0.0090902140 0.0027495993
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.