standardize {robustHD} | R Documentation |
Data standardization
Description
Standardize data with given functions for computing center and scale.
Usage
standardize(x, centerFun = mean, scaleFun = sd)
robStandardize(
x,
centerFun = median,
scaleFun = mad,
fallback = FALSE,
eps = .Machine$double.eps,
...
)
Arguments
x |
a numeric vector, matrix or data frame to be standardized. |
centerFun |
a function to compute an estimate of the center of a
variable (defaults to |
scaleFun |
a function to compute an estimate of the scale of a
variable (defaults to |
fallback |
a logical indicating whether standardization with
|
eps |
a small positive numeric value used to determine whether the robust scale estimate of a variable is too small (an effective zero). |
... |
currently ignored. |
Details
robStandardize
is a wrapper function for robust standardization,
hence the default is to use median
and
mad
.
Value
An object of the same type as the original data x
containing
the centered and scaled data. The center and scale estimates of the
original data are returned as attributes "center"
and "scale"
,
respectively.
Note
The implementation contains special cases for the typically used
combinations mean
/sd
and
median
/mad
in order to reduce
computation time.
Author(s)
Andreas Alfons
See Also
Examples
## generate data
set.seed(1234) # for reproducibility
x <- rnorm(10) # standard normal
x[1] <- x[1] * 10 # introduce outlier
## standardize data
x
standardize(x) # mean and sd
robStandardize(x) # median and MAD