beta: Standardized coefficients of a model.

View source: R/beta.R

betaR Documentation

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 class 'lm'
beta(model, x = TRUE, y = TRUE, skip = NULL, ...)

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

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

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.

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

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.

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.

Examples

# 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

reghelper documentation built on Sept. 3, 2023, 1:07 a.m.