Learn R Programming

reghelper (version 1.1.2)

beta: Standardized coefficients of a model.

Description

beta returns the summary of a linear model where all variables have been standardized. It takes a regression model and standardizes the variables, in order to produce standardized (i.e., beta) coefficients rather than unstandardized (i.e., B) coefficients.

Usage

beta(model, ...)

# S3 method for lm beta(model, x = TRUE, y = TRUE, skip = NULL, ...)

# S3 method for aov beta(model, x = TRUE, y = TRUE, skip = NULL, ...)

# S3 method for glm beta(model, x = TRUE, y = FALSE, skip = NULL, ...)

Value

Returns the summary of a regression model, with the output showing the standardized coefficients, standard error, t-values, and p-values for each predictor. The exact form of the values returned depends on the class of regression model used.

Arguments

model

A fitted linear model of type 'lm', 'glm', or 'aov'.

...

Not currently implemented; used to ensure consistency with S3 generic.

x

Logical. Whether or not to standardize predictor variables.

y

Logical. Whether or not to standardize criterion variables.

skip

A string vector indicating any variables you do not wish to be standardized.

Methods (by class)

  • beta(lm): Standardized coefficients for a linear model.

  • beta(aov): Standardized coefficients for ANOVA.

  • beta(glm): Standardized coefficients for a generalized linear model.

Details

Unlike similar functions, this function properly calculates standardized estimates for interaction terms (by first standardizing each of the predictor variables separately, rather than using the standard deviation of the interaction term itself).

Examples

Run this code
# iris data, showing use with lm()
model1 <- lm(Sepal.Length ~ Petal.Length + Petal.Width, iris)
beta(model1)  # all three variables standardized

model2 <- lm(Sepal.Width ~ Petal.Width + Species, iris)
beta(model2, skip='Species')  # all variables except Species standardized

# mtcars data, showing use with glm()
model1 <- glm(vs ~ wt + hp, data=mtcars, family='binomial')
beta(model1)  # wt and hp standardized, vs is not by default

Run the code above in your browser using DataLab