zscore: Gets the Z scores (standardized residuals)

Description Usage Arguments Author(s) See Also Examples

Description

Z-score is a popular term of what is more formally known as standardized residuals. To calculate the standardized residuals of a data set, the average value and the standard deviation of the data value have to be estimated. This can be done in either a robust way or a non-robust way. Normally the average and the standard deviation are estimated using the mean and sd functions. These functions are sensitive to outliers and a more robust estimates can be obtained by the median and mad (square root) functions.

Usage

1
2
## Default S3 method:
zscore(x, robust=FALSE, ...)

Arguments

x

The vector of data points.

robust

If TRUE, the estimation of the average and standard deviation are robust, otherwise not.

...

Any other arguments mean, median, sd and mad takes, e.g. na.rm=TRUE.

Author(s)

Henrik Bengtsson

See Also

See also mean(), median, sd, and mad. A similar function to zscore is rstandard() (see influence.measures)

Examples

1
2
3
4
5
  x <- rnorm(10000, 0.4, 0.8)
  z <- zscore(x, na.rm=TRUE)
  print(z)
  z <- zscore(x, robust=TRUE, na.rm=TRUE)
  print(z)

HenrikBengtsson/R.basic documentation built on May 6, 2019, 11:51 p.m.