Last data update: 2014.03.03

R: Spatial Signs
spatial.signR Documentation

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, ...)

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.

Details

The spatial signs U of X with location mu and shape V are given by

u_i = (x_i-mu)V^{-0.5}/||(x_i-mu)V^{-0.5}||.

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.

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'.

Author(s)

Klaus Nordhausen, klaus.nordhausen@uta.fi and Seija Sirkiä, seija.sirkia@iki.fi

See Also

HR.Mest

Examples

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)

Results


R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library(ICSNP)
Loading required package: mvtnorm
Loading required package: ICS
> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/ICSNP/spatial.sign.Rd_%03d_medium.png", width=480, height=480)
> ### Name: spatial.sign
> ### Title: Spatial Signs
> ### Aliases: spatial.sign
> ### Keywords: multivariate nonparametric
> 
> ### ** Examples
> 
> 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)
             [,1]        [,2]        [,3]
 [1,] -0.74637086  0.61533244  0.25356762
 [2,]  0.32472971 -0.61800224  0.71597755
 [3,] -0.77508858 -0.62557893  0.08881832
 [4,]  0.07426795  0.47991697  0.87416473
 [5,]  0.15441142  0.34498041 -0.92582160
 [6,]  0.43580792  0.89989834 -0.01595117
 [7,]  0.52671768 -0.83367417 -0.16599960
 [8,]  0.51851281  0.20680133 -0.82968528
 [9,] -0.15948516 -0.92516600 -0.34443047
[10,]  0.58401849  0.50649781 -0.63433616
[11,]  0.88993273 -0.24464066  0.38492946
[12,]  0.39005890  0.03962719  0.91993681
[13,] -0.73545685  0.47205011  0.48607809
[14,] -0.63768750 -0.66095072 -0.39559928
[15,] -0.84436997  0.34290647 -0.41164852
attr(,"center")
[1]  1.3496630  0.6381135 -0.9630392
attr(,"shape")
          [,1]       [,2]       [,3]
[1,] 1.1626251  0.7715352  0.3013364
[2,] 0.7715352  1.9261623 -0.9982745
[3,] 0.3013364 -0.9982745  1.7016210
> spatial.sign(X, center=FALSE, shape=FALSE)
             [,1]        [,2]       [,3]
 [1,] -0.01741992  0.80320768 -0.5954444
 [2,]  0.65686196 -0.49971361  0.5646403
 [3,]  0.57958362 -0.22605720 -0.7829310
 [4,]  0.76739901  0.39802855  0.5026649
 [5,]  0.40336997  0.52668238 -0.7482635
 [6,]  0.69178251  0.57872467 -0.4318735
 [7,]  0.91154274 -0.14617312 -0.3843478
 [8,]  0.58142455  0.48938372 -0.6499608
 [9,]  0.01986775 -0.85502713 -0.5182026
[10,]  0.53587479  0.62710311 -0.5653140
[11,]  0.96615088  0.09157109  0.2411788
[12,]  0.70695219 -0.03117258  0.7065740
[13,]  0.57313508  0.63741799 -0.5149898
[14,] -0.05804359 -0.44056078 -0.8958444
[15,] -0.17680828  0.40147470 -0.8986417
attr(,"center")
[1] 0 0 0
attr(,"shape")
     [,1] [,2] [,3]
[1,]    1    0    0
[2,]    0    1    0
[3,]    0    0    1
> spatial.sign(X, center=colMeans(X), shape=cov(X))
             [,1]        [,2]        [,3]
 [1,] -0.75984746  0.61411093  0.21330634
 [2,]  0.12574264 -0.82643450  0.54881218
 [3,] -0.71064487 -0.70117322 -0.05779256
 [4,]  0.06777213  0.57722479  0.81376808
 [5,]  0.31319652  0.38428843 -0.86846436
 [6,]  0.51304043  0.77839051 -0.36179791
 [7,]  0.37847420 -0.86715910 -0.32371651
 [8,]  0.55089884  0.23846061 -0.79977935
 [9,] -0.25881209 -0.92874172 -0.26543383
[10,]  0.61804600  0.52413604 -0.58591855
[11,]  0.94983010 -0.27068919  0.15668484
[12,]  0.38952302 -0.01702263  0.92085941
[13,] -0.84349048  0.39324523  0.36589890
[14,] -0.62321420 -0.71974631 -0.30589102
[15,] -0.85003951  0.32714466 -0.41280650
attr(,"center")
[1]  1.4606141  0.6373894 -0.6601473
attr(,"shape")
          [,1]       [,2]      [,3]
[1,] 1.8003119  0.3716514  1.481763
[2,] 0.3716514  1.9400195 -1.251207
[3,] 1.4817628 -1.2512065  3.660792
> rm(.Random.seed)
> 
> 
> 
> 
> 
> dev.off()
null device 
          1 
>