std_beta: Standardized beta coefficients and CI of linear and mixed...

Description Usage Arguments Details Value Note References Examples

View source: R/std_b.R

Description

Returns the standardized beta coefficients, std. error and confidence intervals of a fitted linear (mixed) models.

Usage

1
std_beta(fit, type = "std", ci.lvl = 0.95)

Arguments

fit

Fitted linear (mixed) model of class lm or merMod (lme4 package).

type

If fit is of class lm, normal standardized coefficients are computed by default. Use type = "std2" to follow Gelman's (2008) suggestion, rescaling the estimates by deviding them by two standard deviations, so resulting coefficients are directly comparable for untransformed binary predictors.

ci.lvl

Numeric, the level of the confidence intervals.

Details

“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)

Value

A tibble with term names, standardized beta coefficients, standard error and confidence intervals of fit.

Note

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.

References

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

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
# fit linear model
fit <- lm(Ozone ~ Wind + Temp + Solar.R, data = airquality)
# print std. beta coefficients
std_beta(fit)

# print std. beta coefficients and ci, using
# 2 sd and center binary predictors
std_beta(fit, type = "std2")

# std. beta for mixed models
library(lme4)
fit1 <- lmer(Reaction ~ Days + (Days | Subject), sleepstudy)
std_beta(fit)

sjstats documentation built on Nov. 23, 2017, 1:05 a.m.