Article Hudecová and Šiman (2022) describes usage of randomized hyperplane-based ranks and signs for one sample location test for an elliptical distribution. The necessary functions for the computation of interdirections and randomized lift-interdirections and the one sample test statistic are available in the file oneSampleTest.R.

`source("oneSampleTest.R")`

We illustrate the usage of the test with a random sample \(\boldsymbol{X}_1,\dots,\boldsymbol{X}_n\) for \(n=100\) from a \(p\)-variate normal distribution with zero mean and identity variance matrix for \(p=4\).

```
library(mvtnorm)
n=100
p=4
X=rmvnorm(n,mean=rep(0,p),sigma=diag(p))
```

The data are stored in a \(n\times p\) matrix.

Function `one.sample.int.test` computes test statistic \(S\) from equation (3) in Proposition 2 of
Hudecová
and Šiman (2022) and the corresponding p-value computed from the
asymptotic \(\chi^2\) distribution is
reported.

The user needs to specify the score function \(K\) and the number of hyperplanes from
which incomplete interdirections and randomized lift interdirection are
computed. The score functions \(K\) is
specified via the input `KFUN` as

`wilcoxon`for the Wilcoxon score function \(K(x)=x\),`gaussian`for the van der Waerden score function \(K(x)=\sqrt{F^{-1}(x)}\), where \(F\) stands for the CDF function of \(\chi^2_p\) distribution,`sign`for \(K(x)=1\).

The following code computes interdirections using a design set \(\mathcal{Q}_C\) of hyperplanes chosen
independently with replacement such that \(|\mathcal{Q}_C|=4n\) (parameter
`DesI`). Randomized lift-interdirections use a design set \(\mathcal{Q}_L\) chosen independently with
replacement with size \(|\mathcal{Q}_L|=5n\) (parameter
`DesL`). Since the design matrices are chosen randomly, different
results are obtained if the same code is run with different
set.seed.

`one.sample.int.test(X, DesI=4,DesL=5, KFUN="wilcox")`

```
## $S
## [,1]
## [1,] 9.67349
##
## $pval
## [,1]
## [1,] 0.04630192
```

The test statistic based on the van der Waerden score function is obtained as:

`one.sample.int.test(X, DesI=4,DesL=5, KFUN="gaussian")`

```
## $S
## [,1]
## [1,] 7.235502
##
## $pval
## [,1]
## [1,] 0.1239542
```

The test based on “signs” only (\(K(x)=1\)) is obtained as:

`one.sample.int.test(X, DesI=4,DesL=5, KFUN="sign")`

```
## $S
## [,1]
## [1,] 6.108064
##
## $pval
## [,1]
## [1,] 0.191222
```

If one wants to replace the elliptical signs and ranks by the
hyperplane based couterparts, these can be obtained from function
`getSignsAndRanks`, which returns a vector of normalized ranks,
i.e. \(R_i/(n+1)\), \(i=1,\dots,n\), and \(n\times n\) matrix of cosines \(\cos(\pi\cdot
C_{\boldsymbol{X}_i,\boldsymbol{X}_j}(\mathcal{X}_n)/|\mathcal{Q}_C|)\),
for pairs of observations \((i,j)\).

The output is illustrated on a small data of size \(n=5\) with dimension \(2\).

```
X=rmvnorm(n<-5,rep(0,2))
o=getSignsAndRanks(X,DesI=10,DesL=10,IsRank=1)
o
```

```
## $SignMat
## [,1] [,2] [,3] [,4] [,5]
## [1,] 0.9602937 0.3090170 -0.48175367 0.84432793 0.8910065
## [2,] 0.3090170 0.9177546 0.68454711 0.77051324 -0.1564345
## [3,] -0.4817537 0.6845471 0.91775463 0.06279052 -0.8270806
## [4,] 0.8443279 0.7705132 0.06279052 0.96029369 0.5090414
## [5,] 0.8910065 -0.1564345 -0.82708057 0.50904142 0.9822873
##
## $RVec
## [1] 0.8333333 0.1666667 0.3333333 0.6666667 0.5000000
##
## $Status
## [1] 0
```

By default, both interdirections and randomized lift interdirections
are computed. If one wants to obtain only interdirections (i.e. if sign
score function is used) then the computation can be fastened by
specifying `IsRank=0`.

The value of `Status` indicates whether the computation was
successful. Negative values correpond to an error in the input:

```
o=getSignsAndRanks(X,DesI="a",DesL=10,IsRank=0)
o
```

```
## $Status
## [1] -1
```

Note that only some possible input problems are checked.

Hudecová Š. and Šiman M. (2022): Multivariate ranks based on randomized lift-interdirections. Computational Statistics & Data Analysis 172. Link.