Returns the standardized beta coefficients, std. error and confidence intervals of a fitted linear (mixed) models.
std_beta(fit, type = "std", ci.lvl = 0.95)
fit | Fitted linear (mixed) model of class |
---|---|
type | If |
ci.lvl | Numeric, the level of the confidence intervals. |
A tibble
with term names, standardized beta coefficients,
standard error and confidence intervals of fit
.
“Standardized coefficients refer to how many standard deviations a dependent variable will change, per standard deviation increase in the predictor variable. Standardization of the coefficient is usually done to answer the question of which of the independent variables have a greater effect on the dependent variable in a multiple regression analysis, when the variables are measured in different units of measurement (for example, income measured in dollars and family size measured in number of individuals).” (Source: Wikipedia)
For gls
-objects, standardized beta coefficients may be wrong
for categorical variables (factors
), because the model.matrix
for
gls
objects returns the original data of the categorical vector,
and not the 'dummy' coded vectors as for other classes. See, as example:
head(model.matrix(lm(neg_c_7 ~ as.factor(e42dep), data = efc, na.action = na.omit)))
and
head(model.matrix(nlme::gls(neg_c_7 ~ as.factor(e42dep), data = efc, na.action = na.omit)))
.
In such cases, use to_dummy
to create dummies from
factors.
Wikipedia: Standardized coefficient
Gelman A. 2008. Scaling regression inputs by dividing by two standard deviations. Statistics in Medicine 27: 2865–2873. http://www.stat.columbia.edu/~gelman/research/published/standardizing7.pdf
# fit linear model fit <- lm(Ozone ~ Wind + Temp + Solar.R, data = airquality) # print std. beta coefficients std_beta(fit)#> # A tibble: 3 x 5 #> term std.estimate std.error conf.low conf.high #> <chr> <dbl> <dbl> <dbl> <dbl> #> 1 Wind -0.356 0.0700 -0.494 -0.219 #> 2 Temp 0.473 0.0726 0.331 0.615 #> 3 Solar.R 0.164 0.0635 0.0394 0.288# print std. beta coefficients and ci, using # 2 sd and center binary predictors std_beta(fit, type = "std2")#> # A tibble: 3 x 5 #> term std.estimate std.error conf.low conf.high #> <chr> <dbl> <dbl> <dbl> <dbl> #> 1 z.Wind -23.5 4.61 -32.5 -14.5 #> 2 z.Temp 31.3 4.80 21.9 40.7 #> 3 z.Solar.R 10.8 4.18 2.59 19.0# std. beta for mixed models library(lme4) fit1 <- lmer(Reaction ~ Days + (Days | Subject), sleepstudy) std_beta(fit)#> # A tibble: 3 x 5 #> term std.estimate std.error conf.low conf.high #> <chr> <dbl> <dbl> <dbl> <dbl> #> 1 Wind -0.356 0.0700 -0.494 -0.219 #> 2 Temp 0.473 0.0726 0.331 0.615 #> 3 Solar.R 0.164 0.0635 0.0394 0.288