Learn R Programming

ICSNP (version 1.1-2)

spatial.sign: Spatial Signs

Description

Function to obtain the spatial signs of a multivariate dataset. The function can compute the spatial signs also with respect to a given or estimated loacation and scale. If both location and scale have to be estimated the HR.Mest function is used, if only one has to be estimated the, estimation is done using spatial.median or tyler.shape.

Usage

spatial.sign(X, center = TRUE, shape = TRUE, 
             na.action = na.fail, ...)

Value

a matrix with the spatial signs of the data as rows or the univariate signs as a px1 matrix. The centering vector and scaling matrix used are returned as attributes 'center' and 'shape'.

Arguments

X

a numeric data frame or matrix.

center

either a logical value or a numeric vector of length equal to the number of columns of 'X'. See below for more information.

shape

either a logical value or a square numeric matrix with number of columns equal to the number of columns of 'X'. See below for more information.

na.action

a function which indicates what should happen when the data contain 'NA's. Default is to fail.

...

arguments that can be passed on to functions used for the estimation of location and shape.

Author

Klaus Nordhausen and Seija Sirkia

Details

The spatial signs U of X with location \(\mu\) and shape V are given by $$u_{i}=\frac{(x_{i}-\mu)V^{-\frac{1}{2}}}{\| (x_{i}-\mu)V^{-\frac{1}{2}} \|}.$$ If a numeric value is given as 'center' and/or 'shape' these are used as \(\mu\) and/or V in the above formula. If 'center' and/or 'shape' are 'TRUE' the values for \(\mu\) and/or V are estimated, if 'FALSE' the origin is used as the value of \(\mu\) and/or the identity matrix as the value of V.

In the special case of univariate data the univariate signs of the data (centered if requested) are returned and the shape parameter is redundant.

See Also

HR.Mest

Examples

Run this code
set.seed(654321)
cov.matrix <- matrix(c(3,2,1,2,4,-0.5,1,-0.5,2), ncol=3)
X <- rmvnorm(15, c(1,0,-1), cov.matrix)
spatial.sign(X)
spatial.sign(X, center=FALSE, shape=FALSE)
spatial.sign(X, center=colMeans(X), shape=cov(X))
rm(.Random.seed)

Run the code above in your browser using DataLab