This function either centers and scales a continuous variable and provides options for binary variables, or returns an untransformed variable from a centered and scaled variable.
This is a vector to be centered and scaled, or to be
This argument indicates how binary variables will be
treated, and defaults to
These arguments are required only when
Gelman (2008) recommends centering and scaling continuous predictors
to facilitate MCMC convergence and enable comparisons between
coefficients of centered and scaled continuous predictors with
coefficients of untransformed binary predictors. A continuous
predictor is centered and scaled as follows:
x.cs <- (x -
mean(x)) / (2*sd(x)). This is an improvement over the usual
practice of standardizing predictors, which is
x.z <- (x -
mean(x)) / sd(x), where coefficients cannot be validly compared
between binary and continuous predictors.
In MCMC, such as in
LaplacesDemon, a centered and
scaled predictor often results in a higher effective sample size
ESS), and therefore the chain mixes better. Centering
and scaling is a method of re-parameterization to improve mixing.
Griffin and Brown (2013) also assert that the user may not want to scale predictors that are measured on the same scale, since scaling in this case may increase noisy, low signals. In this case, centering (without scaling) is recommended. To center a predictor, subtract its mean.
CenterScale function returns a centered and scaled vector,
or the untransformed vector.
Gelman, A. (2008). "Scaling Regression Inputs by Dividing by Two Standard Devations". Statistics in Medicine, 27, p. 2865–2873.
Griffin, J.E. and Brown, P.J. (2013) "Some Priors for Sparse Regression Modelling". Bayesian Analysis, 8(3), p. 691–702.
1 2 3 4 5
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.