rescale {arm} | R Documentation |
This function standardizes a variable by centering and dividing by 2 sd's with exceptions for binary variables.
rescale(x, binary.inputs)
x |
a vector |
binary.inputs |
options for standardizing binary variables |
the standardized vector
Andrew Gelman gelman@stat.columbia.edu; Yu-Sung Su ys463@columbia.edu
Andrew Gelman, Scaling regression inputs by dividing by two standard deviations. http://www.stat.columbia.edu/~gelman/research/unpublished/standardizing.pdf
# Set up the fake data n <- 100 x <- rnorm (n, 2, 1) x1 <- rnorm (n) x1 <- (x1-mean(x1))/(2*sd(x1)) # standardization x2 <- rbinom (n, 1, .5) b0 <- 1 b1 <- 1.5 b2 <- 2 y <- rbinom (n, 1, invlogit(b0+b1*x1+b2*x2)) rescale(x, "full2") rescale(y, "center")