Learn R Programming

lsr (version 1.0.0)

standardCoefs: Standardised regression coefficients

Description

Calculates standardised regression coefficients (beta weights) for a linear model.

Usage

standardCoefs(x)

Value

A matrix with one row per predictor (excluding the intercept) and two columns: b (unstandardised coefficient) and beta

(standardised coefficient).

Arguments

x

A linear model, as returned by lm.

Details

Standardised coefficients are the regression coefficients that would result from fitting the model after scaling all predictors and the outcome to have mean 0 and variance 1. They can be useful for comparing the relative magnitude of predictors measured on different scales, though this comparison should be interpreted with care.

Note that when a model contains interaction terms, the interaction column is also standardised as a whole, rather than being constructed from standardised versions of the constituent predictors.

See Also

Examples

Run this code
X1 <- c(0.69, 0.77, 0.92, 1.72, 1.79, 2.37, 2.64, 2.69, 2.84, 3.41)
Y <- c(3.28, 4.23, 3.34, 3.73, 5.33, 6.02, 5.16, 6.49, 6.49, 6.05)

# simple linear regression
model1 <- lm(Y ~ X1)
coefficients(model1) # unstandardised
standardCoefs(model1) # unstandardised and standardised side by side

# multiple regression
X2 <- c(0.19, 0.22, 0.95, 0.43, 0.51, 0.04, 0.12, 0.44, 0.38, 0.33)
model2 <- lm(Y ~ X1 + X2)
standardCoefs(model2)

# model with an interaction term
model3 <- lm(Y ~ X1 * X2)
standardCoefs(model3)

Run the code above in your browser using DataLab