Skip to contents

This function transform the input data via z-standardisation. See the Details section below for further information.

Usage

zStandardisationForVector(x, robust = FALSE, na.rm = TRUE)

Arguments

x

a (named) numerical vector.

robust

logical, whether to compute a robust z-standardisation.

na.rm

logical, whether to remove NA values before the computation.

Value

A vector with the transformed values.

Details

The z-standardisation (or z-score normalisation) is a method for transforming the data so that it has a mean of zero and a standard deviation of one. It is computed as:

$$z(x) = \frac{x - \mu}{\sigma}$$

where \(\mu\) and \(\sigma\) are the mean and standard deviation of the population, respectively.

Since z-scores can be affected by unusually large or small data values, we can also compute a more robust modified version as:

$$z(x) = \frac{x - \mathrm{median}}{\mathrm{MAD}}$$

where \(\mathrm{MAD}\) is the median absolute deviation of the population.

References

https://en.wikipedia.org/wiki/Standard_score

Author

Alessandro Barberis