center_scale: Standardize inputs into a regression model

Description Usage Arguments Examples

Description

Standardizes regression input columns to have comparable regression coefficients. Rules are as follows: * categoricals: ignore (leave as dummy vars with 0/1) * binaries: ignore (leave as 0/1) * continuous: divide by 2 std dev. if scale = F; or reset so sd = 1, mean = 0 if center = T, scale = T; divided by root mean squared if scale = T, center = F Based off of Andrew Gelman's suggestions: http://andrewgelman.com/2009/07/11/when_to_standar/

Usage

1
center_scale(df, center = TRUE, scale = TRUE, cols2ignore = NA)

Arguments

df

data frame containing all the data

center

binary if the continuous data should be centered (set so mean = 0)

scale

binary if the data should be scaled so the new standard deviation is 1 (if centered), or the value divided by the RMS (if not centered). If false, the column will merely be divided by 2 std. dev.

Examples

1
2
3
scaledcenter_mtcars = center_scale(mtcars)
scaled_mtcars = center_scale(mtcars, center = FALSE)
adj_mtcars = center_scale(mtcars, center = FALSE, scale = FALSE)

flaneuse/svywrangler documentation built on May 24, 2019, 2:49 p.m.