Learn R Programming

sjstats (version 0.2.0)

std_beta: Standardized Beta coefficients and CI of lm and mixed models

Description

Returns the standardized beta coefficients and confidence intervals of a fitted linear (mixed) models, i.e. fit must either be of class lm or merMod.

Usage

std_beta(fit, include.ci = FALSE, type = "std")

Arguments

fit
Fitted linear (mixed) model of class lm or merMod (lme4 package).
include.ci
Logical, if TRUE, a data frame with confidence intervals will be returned, when fit is of class lm. If fit is a lmerMod object (lme4 package), always returns standard error instead of confidence intervals (hence, this parameter will be ignored when fit is a lmerMod object).
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.

Value

A vector with standardized beta coefficients of the fitted linear model, or a data frame with standardized beta coefficients and confidence intervals, if include.ci = TRUE.

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)

References

Examples

Run this code
# 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
std_beta(fit, include.ci = TRUE)

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

Run the code above in your browser using DataLab