R: Oja Signed Ranks - Affine Equivariant Multivariate Signed...
ojaSignedRank
R Documentation
Oja Signed Ranks – Affine Equivariant Multivariate Signed Ranks
Description
The function computes the Oja signed rank of a point x w.r.t.
a data set X or, if no
point x is given, the Oja signed ranks of all points in X.
Usage
ojaSignedRank(X, x = NULL, p = NULL, silent = FALSE,
na.action = na.fail)
Arguments
X
numeric data.frame or matrix containing the data points as rows.
x
NULL or a numeric vector, the point for which the Oja
signed rank should be computed.
p
NULL or a number between 0 and 1 which specifies the
fraction of hyperplanes to be used for subsampling. If p = 1,
no subsampling is done. If p = NULL, the value of p is
determined based on the size of the data set. See details.
silent
logical, if subsampling is done or the expected
computation time is too long, a warning message will be printed
unless silent is TRUE. The default is FALSE.
na.action
a function which indicates what should happen
when the data contain 'NA's. Default is to fail.
Details
The function computes the Oja signed rank of the point x w.r.t.
the data set X or, if no x is specified, the Oja signed
ranks of all data points in X w.r.t. X. For a definition
of Oja signed rank see Hettmansperger et al. (1997) formula (9).
The matrix X needs to have at least as many rows as columns in
order to give sensible results. The vector x has to be of length
ncol(X). If x is specified, a vector of length
ncol(X) is returned. Otherwise the return value is a matrix of
the same dimensions as X where the i-th row contains the
Oja rank of the i-th row of X.
The function will also work for matrices X with only one column
and also vectors. Then (univariate) signed ranks are returned.
For n = nrow(X) data points in R^k, where k = ncol(X),
the computation of the Oja signed rank necessitates the evaluation of
N = 2^k*choose(n,k)
hyperplanes in R^k. Thus for large data sets the function offers a
subsampling option in order to deliver (approximate) results within
reasonable time. The subsampling fraction is controlled by the parameter p:
If p < 1 is passed to the function, the computation is
based on a random sample of only p N of all possible N
hyperplanes. If p is not specified (which defaults to p = NULL),
it is automatically determined based on n and k to yield a
sensible trade-off between accuracy and computing time.
If 2^k*choose(n,k)*k^3 < 6e+06, the
sample fraction p is set to 1 (no subsampling). If all Oja signed ranks of X are requested, a hyperplane sample is
drawn once and all Oja signed ranks are then computed based on this sample.
Finally, subsampling is feasible. Even for very small p useable
results can be expected, see e.g. the examples for the function ojaRCM.
Value
Either a numeric vector, the Oja signed rank of x, or
a matrix of the same dimensions as X containing the Oja signed ranks of X as rows.
Author(s)
Jyrki M<c3><83><c2><b6>tt<c3><83><c2><b6>nen
References
Hettmansperger, T. P., M<c3><83><c2><b6>tt<c3><83><c2><b6>nen, J. and Oja, H. (1997),
Affine invariant multivariate one-sample signed-rank tests, J.
Amer. Statist. Assoc.,
92, 1591–1600.
Oja, H. (1999), Affine invariant multivariate sign and rank tests
and corresponding estimates: A review,
Scand. J. Statist., 26, 319–343.
See Also
ojaSign,
ojaRank,
ojaRCM,
hyperplane
Examples
set.seed(123)
X <- rmvnorm(n = 30,mean = c(0,0)) # from package 'mvtnorm'
ojaSignedRank(X)
ojaSignedRank(X, x = c(0,0)) # zero
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(OjaNP)
Loading required package: ICS
Loading required package: mvtnorm
Loading required package: ICSNP
> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/OjaNP/ojaSignedRank.Rd_%03d_medium.png", width=480, height=480)
> ### Name: ojaSignedRank
> ### Title: Oja Signed Ranks - Affine Equivariant Multivariate Signed Ranks
> ### Aliases: ojaSignedRank
> ### Keywords: multivariate nonparametric
>
> ### ** Examples
>
> set.seed(123)
> X <- rmvnorm(n = 30,mean = c(0,0)) # from package 'mvtnorm'
> ojaSignedRank(X)
[,1] [,2]
[1,] -0.495140906 -0.24248888
[2,] 1.028715285 0.08127564
[3,] 0.290188478 0.83185037
[4,] 0.261757295 -0.62036253
[5,] -0.617016938 -0.42697620
[6,] 0.965337851 0.31815463
[7,] 0.324103284 0.08202580
[8,] -0.255796333 0.74927547
[9,] 0.104023629 -0.81706011
[10,] 0.574884606 -0.34072745
[11,] -0.911789729 -0.18248099
[12,] -0.845432808 -0.55862003
[13,] -0.518000955 -0.80814898
[14,] 0.781225701 0.12052760
[15,] -0.665767368 0.51360039
[16,] 0.337555068 -0.28010413
[17,] 0.709049387 0.69609915
[18,] 0.682462121 0.59246065
[19,] 0.508356007 -0.09618360
[20,] -0.232840180 -0.37640266
[21,] -0.648673437 -0.20551265
[22,] -0.518867112 0.65524719
[23,] 0.779176672 -0.41907208
[24,] -0.346124229 -0.47628708
[25,] 0.726637949 -0.09176243
[26,] 0.182886537 -0.06540457
[27,] 0.150310507 0.74652224
[28,] 0.005639374 0.75941964
[29,] -0.954536980 0.20182180
[30,] 0.055605876 0.20560378
> ojaSignedRank(X, x = c(0,0)) # zero
[1] 0.000000e+00 -2.990903e-21
>
>
>
>
>
> dev.off()
null device
1
>