Returns the standardized beta coefficients, std. error and confidence intervals of a fitted linear (mixed) models.
std_beta(fit, ...) # S3 method for merMod std_beta(fit, ci.lvl = 0.95, ...) # S3 method for lm std_beta(fit, type = "std", ci.lvl = 0.95, ...) # S3 method for gls std_beta(fit, type = "std", ci.lvl = 0.95, ...)
fit | Fitted linear (mixed) model of class |
---|---|
... | Currently not used. |
ci.lvl | Numeric, the level of the confidence intervals. |
type | If |
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)#> term std.estimate std.error conf.low conf.high #> 1 Wind -0.3564122 0.06996619 -0.4935434 -0.2192810 #> 2 Temp 0.4731461 0.07260889 0.3308353 0.6154569 #> 3 Solar.R 0.1638655 0.06351430 0.0393798 0.2883513# print std. beta coefficients and ci, using # 2 sd and center binary predictors std_beta(fit, type = "std2")#> term std.estimate std.error conf.low conf.high #> 1 Wind -23.71992 4.656386 -32.846272 -14.59358 #> 2 Temp 31.48879 4.832262 22.017729 40.95985 #> 3 Solar.R 10.90557 4.226999 2.620802 19.19034# std. beta for mixed models library(lme4) fit1 <- lmer(Reaction ~ Days + (Days | Subject), sleepstudy) std_beta(fit)#> term std.estimate std.error conf.low conf.high #> 1 Wind -0.3564122 0.06996619 -0.4935434 -0.2192810 #> 2 Temp 0.4731461 0.07260889 0.3308353 0.6154569 #> 3 Solar.R 0.1638655 0.06351430 0.0393798 0.2883513