Scales a design matrix so that all non-categorical columns have a mean of 0 and an standard deviation of 1.
centreVector of column means. The first value is the outcome variable, all other variables are the predictors.
scalesVector of column standard deviations. The first value is the outcome variable, all other variables are the predictors.
new()Uses dat to determine the relevant column means and standard deviations to use
when scaling and un-scaling future datasets. Implicitly assumes that new datasets
have the same column order as dat
scalerConstructor$new(dat)datA data.frame or matrix. All columns must be numeric (i.e dummy variables,
must have already been expanded out).
Categorical columns (as determined by those who's values are entirely 1 or 0)
will not be scaled. This is achieved by setting the corresponding values of centre
to 0 and scale to 1.
scale()Scales a dataset so that all continuous variables have a mean of 0 and a standard deviation of 1.
scalerConstructor$scale(dat)datA data.frame or matrix whose columns are all numeric (i.e. dummy
variables have all been expanded out) and whose columns are in the same
order as the dataset used in the initialization function.
unscale_sigma()Unscales a sigma value (or matrix) as estimated by a linear model
using a design matrix scaled by this object. This function only
works if the first column of the initialisation data.frame was the outcome
variable.
scalerConstructor$unscale_sigma(sigma)sigmaA numeric value or matrix.
A numeric value or matrix
unscale_beta()Unscales a beta value (or vector) as estimated by a linear model
using a design matrix scaled by this object. This function only
works if the first column of the initialization data.frame was the outcome
variable.
scalerConstructor$unscale_beta(beta)betaA numeric vector of beta coefficients as estimated from a linear model.
A numeric vector.
clone()The objects of this class are cloneable with this method.
scalerConstructor$clone(deep = FALSE)deepWhether to make a deep clone.
The object initialisation is used to determine the relevant mean and SD's to scale by and then the scaling (and un-scaling) itself is performed by the relevant object methods.
Un-scaling is done on linear model Beta and Sigma coefficients. For this purpose the first column on the dataset to be scaled is assumed to be the outcome variable with all other variables assumed to be post-transformation predictor variables (i.e. all dummy variables have already been expanded).