stand: Standardize regression inputs by centering around the mean...

View source: R/stand.R

standR Documentation

Standardize regression inputs by centering around the mean and dividing by 2 standard deviations

Description

Standardize regression inputs by centering around the mean and dividing by 2 standard deviations

Usage

stand(x, cols = NULL)

Arguments

x

A vector, matrix, or dataframe

cols

A character vector of column names, a numeric vector of column indices, or a formula

Details

Inspired by the standardize function in the arm package. Numeric predictors are rescaled by subtracting the mean and dividing by 2 standard deviations. Binary predictors are rescaled to have a mean of 0 and a difference of 1 between their two levels. Non-numeric variables with more than two values are unchanged.

Value

A numeric vector, a matrix, or a dataframe

Author(s)

Jason Grafmiller

See Also

standardize

Examples

## Not run: 
x <- rnorm(10, 5, 3)
x
stand(x)

y <- sample(c("A", "B"), 10, replace = T, prob = c(.8, .2))
y
stand(y)

df <- data.frame(X = x, Y = y)
df
stand(df, 1:2)
stand(df, Y ~ X)

## End(Not run)

jasongraf1/VADIS documentation built on July 19, 2023, 10:26 p.m.