Description Usage Arguments Details Value Author(s) See Also Examples
View source: R/coef_standardized.R
Compute the standardized regression coefficients (beta) from an object of class lm
).
1 2 3 4 5 6 7 8 9 10 |
obj |
( |
x |
|
... |
further parameters to |
digits |
(integer) number of decimal places to round the answer to. Default is 3. |
object |
|
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()
.
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.
Vilmantas Gegzna (modified function written by Thomas D. Fletcher).
stats::lm()
in package stats.
QuantPsyc::lm.beta()
in package QuantPsyc.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | data(USJudgeRatings)
us <- USJudgeRatings
names(us)
lm1 <- lm(CONT ~ INTG + DMNR + log(DILG), data = us)
coef_standardized(lm1)
lm2 <- lm(CONT ~ INTG + DMNR * DILG, data = us)
coef_standardized(lm2)
summary(coef_standardized(lm2))
# Do not include intercept
lm3 <- lm(CONT ~ 0 + INTG, data = us)
coef_standardized(lm3)
summary(coef_standardized(lm3))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.