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
.
ojaSignedRank(X, x = NULL, p = NULL, silent = FALSE,
na.action = na.fail)
numeric data.frame or matrix containing the data points as rows.
NULL
or a numeric vector, the point for which the Oja
signed rank should be computed.
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.
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
.
a function which indicates what should happen when the data contain 'NA's. Default is to fail.
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.
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 \(N k^3 < 6 \cdot 10^6\), 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
.
Fischer D, Mosler K, M<U+00F6>tt<U+00F6>nen J, Nordhausen K, Pokotylo O and Vogel D (2020). <U+201C>Computing the Oja Median in R: The Package OjaNP.<U+201D> Journal of Statistical Software, 92(8), pp. 1-36. doi: 10.18637/jss.v092.i08 (URL: http://doi.org/10.18637/jss.v092.i08).
Hettmansperger, T. P.,\ M<U+00F6>tt<U+00F6>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.
# NOT RUN {
set.seed(123)
X <- rmvnorm(n = 30,mean = c(0,0)) # from package 'mvtnorm'
ojaSignedRank(X)
ojaSignedRank(X, x = c(0,0)) # zero
# }
Run the code above in your browser using DataLab