CenterScale {LaplacesDemon}  R Documentation 
Centering and Scaling
Description
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.
Usage
CenterScale(x, Binary="none", Inverse=FALSE, mu, sigma, Range, Min)
Arguments
x 
This is a vector to be centered and scaled, or to be
untransformed if 
Binary 
This argument indicates how binary variables will be
treated, and defaults to 
Inverse 
Logical. If 
mu , sigma , Range , Min 
These arguments are required only when

Details
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 reparameterization 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.
Value
The CenterScale
function returns a centered and scaled vector,
or the untransformed vector.
References
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.
See Also
ESS
,
IterativeQuadrature
,
LaplaceApproximation
,
LaplacesDemon
, and
PMC
.
Examples
### See the LaplacesDemon function for an example in use.
library(LaplacesDemon)
x < rnorm(100,10,1)
x.cs < CenterScale(x)
x.orig < CenterScale(x.cs, Inverse=TRUE, mu=mean(x), sigma=sd(x))