Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

spatialSign

Compute the multivariate spatial sign


Description

Compute the spatial sign (a projection of a data vector to a unit length circle). The spatial sign of a vector w is w /norm(w).

Usage

spatialSign(x, ...)

## Default S3 method:
spatialSign(x, na.rm = TRUE, ...)

## S3 method for class 'matrix'
spatialSign(x, na.rm = TRUE, ...)

## S3 method for class 'data.frame'
spatialSign(x, na.rm = TRUE, ...)

Arguments

x

an object full of numeric data (which should probably be scaled). Factors are not allowed. This could be a vector, matrix or data frame.

...

Not currently used.

na.rm

A logical; should missing data be removed when computing the norm of the vector?

Value

A vector, matrix or data frame with the same dim names of the original data.

Author(s)

Max Kuhn

References

Serneels et al. Spatial sign preprocessing: a simple way to impart moderate robustness to multivariate estimators. J. Chem. Inf. Model (2006) vol. 46 (3) pp. 1402-1409

Examples

spatialSign(rnorm(5))

spatialSign(matrix(rnorm(12), ncol = 3))

# should fail since the fifth column is a factor
try(spatialSign(iris), silent = TRUE)

spatialSign(iris[,-5])

trellis.par.set(caretTheme())
featurePlot(iris[,-5], iris[,5], "pairs")
featurePlot(spatialSign(scale(iris[,-5])), iris[,5], "pairs")

caret

Classification and Regression Training

v6.0-86
GPL (>= 2)
Authors
Max Kuhn [aut, cre], Jed Wing [ctb], Steve Weston [ctb], Andre Williams [ctb], Chris Keefer [ctb], Allan Engelhardt [ctb], Tony Cooper [ctb], Zachary Mayer [ctb], Brenton Kenkel [ctb], R Core Team [ctb], Michael Benesty [ctb], Reynald Lescarbeau [ctb], Andrew Ziem [ctb], Luca Scrucca [ctb], Yuan Tang [ctb], Can Candan [ctb], Tyler Hunt [ctb]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.