coef_standardized: *!!* Compute Standardized Regression Coefficients

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/coef_standardized.R

Description

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

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
coef_standardized(obj)

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

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

## S3 method for class '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.

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().

Value

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

Author(s)

Vilmantas Gegzna (modified function written by Thomas D. Fletcher).

See Also

Examples

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

GegznaV/BioStat documentation built on Aug. 14, 2020, 9:30 p.m.