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)
obj | ( |
---|---|
x |
|
... | further parameters to |
digits | (integer) number of decimal places to round the answer to. Default is 3. |
object |
|
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.
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()
.
stats::lm()
in package stats.
QuantPsyc::lm.beta()
in package QuantPsyc.
#> [1] "CONT" "INTG" "DMNR" "DILG" "CFMG" "DECI" "PREP" "FAMI" "ORAL" "WRIT" #> [11] "PHYS" "RTEN"#> Standardized Regression Coefficients: #> INTG DMNR log(DILG) #> -0.293 -0.316 0.533#> Standardized Regression Coefficients: #> INTG DMNR DILG DMNR:DILG #> -0.266 -0.626 0.301 0.495#> 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#> Standardized Regression Coefficients: #> INTG #> 0.751#> Summary of Standardized Regression Coefficients: #> regressor coeff standardized_coeff influence_rank #> 1 (Intercept) 0.0000000 NA NA #> 2 INTG 0.9174981 0.751 1