# shapematrices: Shape matrices based on spatial ranks and signed ranks In SpatialNP: Multivariate Nonparametric Methods Based on Spatial Signs and Ranks

## Description

Iterative algorithms to find shape matrices based on spatial signs and ranks and the k-step versions of these.

## Usage

 ``` 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17``` ``` spatial.shape(X, score = c("sign", "symmsign", "rank", "signrank"), fixed.loc = FALSE, location = NULL, init = NULL, steps = Inf, eps = 1e-06, maxiter = 100, na.action = na.fail) signs.shape(X, fixed.loc = FALSE, location = NULL, init = NULL, steps = Inf, eps = 1e-6, maxiter = 100, na.action = na.fail) symmsign.shape(X, init = NULL, steps = Inf, eps = 1e-6, maxiter = 100, na.action = na.fail) rank.shape(X, init = NULL, steps = Inf, eps = 1e-06, maxiter = 100, na.action = na.fail) signrank.shape(X, fixed.loc = FALSE, location = NULL, init = NULL, steps = Inf, eps = 1e-06, maxiter = 100, na.action = na.fail) ```

## Arguments

 `X` a matrix or a data frame `score` a character string indicating which transformation of the observations should be used `fixed.loc` a logical, see details `location` an optional vector giving the location of the data or the initial value for the location if it is estimated `init` an optional starting value for the iteration `steps` fixed number of iteration steps to take, if `Inf` iteration is repeated until convergence (or until `maxiter` steps) `eps` tolerance for convergence `maxiter` maximum number of iteration steps. Ignored if `steps` is finite `na.action` a function which indicates what should happen when the data contain 'NA's. Default is to fail.

## Details

`sign.shape` (Tyler's shape matrix), `symmsign.shape` (Duembgen's shape matrix), `rank.shape` and `signrank.shape` are the so called inner standardization matrices of location etc. tests based on spatial signs and ranks. When data is standardized using these matrices the corresponding sign or rank scores will appear “uncorrelated”: the corresponding outer standardization matrices will be proportional to the identity matrix, see examples.

`spatial.shape` is a wrapper function for a unified access to all four shape estimates. The choice of estimate is done via `score`:

• `"sign"` for `signs.shape`

• `"symmsign"` for `symmsign.shape`

• `"rank"` for `rank.shape`

• `"signrank"` for `signrank.shape`

`signrank.shape` and `sign.shape` include options to compute the shape matrix either with respect to fixed location (`fixed.loc = TRUE`) or so that the location and the shape are estimated simultaneously (`fixed.loc = FALSE`).

## Value

The estimate matrix with the (final estimate of or given) location vector as attribute `"location"`.

## Author(s)

Seija Sirkia, [email protected], Jari Miettinen, [email protected]

## References

Oja, H., Randles R. (2004) Multivariate Nonparametric Tests. Statistical Science 19, 598-605.

Sirkia et al. (2009) Tests and estimates of shape based on spatial signs and ranks. Journal of Nonparametric Statistics, 21, 155-176.

Sirkia, S., Taskinen, S., Oja, H. (2007) Symmetrised M-estimators of scatter. Journal of Multivariate Analysis, 98, 1611-1629.

`tyler.shape`, `duembgen.shape`, also spatial sign and rank covariance matrices and spatial signs and ranks
 ```1 2 3 4 5 6 7 8 9``` ```A<-matrix(c(1,2,-3,4,3,-2,-1,0,4),ncol=3) X<-matrix(rnorm(1500),ncol=3)%*%t(A) symmsign.shape(X) to.shape(symmsign.shape(X),trace=3) spatial.shape(X,score="sign") spatial.shape(X,score="sign",fixed.loc=TRUE) to.shape(A%*%t(A)) # one-step shape estimate based on spatial ranks and covariance matrix: spatial.shape(X,score="rank",init=cov(X),steps=1) ```