Compute the standardized regression coefficients (beta) from an object of class lm).

coef_standardized(obj)

# S3 method for lm_beta
print(x, ..., digits = 3)

# S3 method for lm_beta
summary(object, ..., digits = 3)

# S3 method for lm_beta_summary
print(x, ..., digits = 3)

Arguments

obj

(lm object) A result of function lm().

x

lm_beta object.

...

further parameters to print method.

digits

(integer) number of decimal places to round the answer to. Default is 3.

object

lm_beta object.

Value

Object of class lm_beta which is a list with 2 named fields:

  • b named numeric vector with regression coefficients (not standardized);

  • beta named numeric vector with standardized coefficients from lm() model.

Details

This function is inspired by function QuantPsyc::lm.beta() written by Thomas D. Fletcher.
coef_standardized() provides standardized coefficients even when interaction members are present. This is achieved by computing whole model matrix (with all right-hand side members of formula used in call of lm()) and calculating standard deviations of each regressor (including interaction members) based on these columns.
coef_standardized() does not fail if intercept is not present.

The remaining calculations are the same as in QuantPsyc::lm.beta().

See also

Examples

data(USJudgeRatings) us <- USJudgeRatings names(us)
#> [1] "CONT" "INTG" "DMNR" "DILG" "CFMG" "DECI" "PREP" "FAMI" "ORAL" "WRIT" #> [11] "PHYS" "RTEN"
lm1 <- lm(CONT ~ INTG + DMNR + log(DILG), data = us) coef_standardized(lm1)
#> Standardized Regression Coefficients: #> INTG DMNR log(DILG) #> -0.293 -0.316 0.533
lm2 <- lm(CONT ~ INTG + DMNR * DILG, data = us) coef_standardized(lm2)
#> Standardized Regression Coefficients: #> INTG DMNR DILG DMNR:DILG #> -0.266 -0.626 0.301 0.495
summary(coef_standardized(lm2))
#> Summary of Standardized Regression Coefficients: #> regressor coeff standardized_coeff influence_rank #> 1 (Intercept) 9.57813871 NA NA #> 2 INTG -0.32520383 -0.266 4 #> 3 DMNR -0.51532509 -0.626 1 #> 4 DILG 0.31487864 0.301 3 #> 5 DMNR:DILG 0.03270199 0.495 2
# Do not include intercept lm3 <- lm(CONT ~ 0 + INTG, data = us) coef_standardized(lm3)
#> Standardized Regression Coefficients: #> INTG #> 0.751
summary(coef_standardized(lm3))
#> Summary of Standardized Regression Coefficients: #> regressor coeff standardized_coeff influence_rank #> 1 (Intercept) 0.0000000 NA NA #> 2 INTG 0.9174981 0.751 1