This document illustrates the use of the test of axial symmetry via integrated ranks scores proposed by Hudecová and Šiman (2022). The file ASTvIRS.R contains two functions which compute test statistic $$T_n$$ of (5) and the corresponding p-value from the asymptotic $$\chi^2_{m-1}$$ distribution. The test statistic may use three different score functions $$\phi$$:

• the quantile function of the standard normal distribution $$\mathsf{N}(0,1)$$ (leading to normal/van der Waerden scores),
• $$\phi(t)=\text{sgn}(t-1/2)$$ (leading to sign scores),
• $$\phi(t)=t-\frac{1}{2}$$ (leading to Wilcoxon’s scores).

Furthermore, the matrix $$\widehat{\boldsymbol{\Sigma}}$$ can be computed either as specified after Proposition 1, or as $$\widehat{\boldsymbol{\Sigma}}_0$$ from Remark 1. Recall that $$T_n$$ combined with $$\widehat{\boldsymbol{\Sigma}}_0$$ is theoretically justified only in certain special cases, namely if $$\boldsymbol{\Gamma}_{\boldsymbol{u}}^\top\boldsymbol{Y}$$ and $$\boldsymbol{u}^\top\boldsymbol{Y}$$ are independent, or if the sign score function is employed.

The functions AST and AST.gen allow for the following combinations, specified by the parameter Stat:

1. normal scores with $$\widehat{\boldsymbol{\Sigma}}_0$$ ($$T_{N0}$$),
2. normal scores with $$\widehat{\boldsymbol{\Sigma}}$$ ($$T_{N}$$),
3. sign scores with $$\widehat{\boldsymbol{\Sigma}}_0$$ ($$T_{S0}$$),
4. sign scores with $$\widehat{\boldsymbol{\Sigma}}$$ ($$T_{S}$$),
5. Wilcoxon scores with $$\widehat{\boldsymbol{\Sigma}}_0$$ ($$T_{W0}$$),
6. Wilcoxon scores with $$\widehat{\boldsymbol{\Sigma}}$$ ($$T_{W}$$).

The expressions in parentheses correspond to the notation used in Section 4: Empirical Study of Hudecová and Šiman (2022).

source("ASTvIRS.R")

# 1. Bivariate data

Consider first $$m=2$$. Let $$\boldsymbol{Y}_1,\dots,\boldsymbol{Y}_n$$ be iid random vectors generated from a zero-centered bivariate normal distribution with correlation $$\rho$$ and unit marginal variances. In the example below, we take $$\rho=0.5$$ and sample size $$n=100$$.

library(mvtnorm)
n=100
rho=0.5
set.seed(123)
Y=rmvnorm(n, mean=c(0,0),sigma=matrix(c(1,rho,rho,1),nrow=2))

Let $$\alpha\in[0,\pi]$$ be given and $\boldsymbol{u}=(\cos \alpha,\sin \alpha)^\top.$ Consider the null hypothesis $H_0: \quad \text{ the distribution of } \boldsymbol{Y} \ \text{ is axially symmetric around a line in direction } \boldsymbol{u}.$

The code below illustrates how the test via integrated rank scores can be conducted for $$\alpha=0$$ and $$\alpha=\pi/4$$ for normal scores with $$\widehat{\boldsymbol{\Sigma}}$$ (i.e, for Stat = 2 corresponding to test statistic $$T_N$$).

AST(YMat=Y,Angle=0,Stat=2)
## $Tn ## [,1] ## [1,] 9.007585 ## ##$pval
##             [,1]
## [1,] 0.002688615
AST(YMat=Y,Angle=pi/4,Stat=2)
## $Tn ## [,1] ## [1,] 0.9897857 ## ##$pval
##           [,1]
## [1,] 0.3197948

The function AST.gen requires as input both the directional vector $$\boldsymbol{u}$$ and the orthonormal matrix $$\boldsymbol{\Gamma}_{\boldsymbol{u}}$$. It might be useful for $$m>2$$. Note that the orthonormality of $$\boldsymbol{\Gamma}_{\boldsymbol{u}}$$ is not checked by the function AST.gen.

u=c(1,0)
Gamma=matrix(c(0,1),nrow=2)
AST.gen(YMat=Y,UVec=u,GammaUMat=Gamma,Stat=2)
## $Tn ## [,1] ## [1,] 9.007585 ## ##$pval
##             [,1]
## [1,] 0.002688615
u=c(1,1)/sqrt(2)
Gamma=matrix(c(1,-1)/sqrt(2),nrow=2)
AST.gen(YMat=Y,UVec=u,GammaUMat=Gamma,Stat=2)
## $Tn ## [,1] ## [1,] 0.9897857 ## ##$pval
##           [,1]
## [1,] 0.3197948

# 2. General multivariate data

For a general data with $$m\geq 2$$, the function AST tests the axial symmetry around a line in direction $\boldsymbol{u}=(\cos \alpha, \sin \alpha, 0, \dots, 0)^\top$ for certain angle $$\alpha\in[0,\pi]$$. The function AST.gen can be used for a general $$\boldsymbol{u}$$ specified by the user with a suitable matrix $$\boldsymbol{\Gamma}_{\boldsymbol{u}}$$.

The code below illustrates how to compute $$T_{S}$$ (sign scores) statistic for data from a trivariate distribution:

rho=0.5
set.seed(123)
Y=rmvnorm(n, mean=c(0,0,0),sigma=matrix(c(1,rho,rho,rho,1,rho,rho,rho,1),nrow=3))

AST(YMat=Y,Angle=0,Stat=4)
## $Tn ## [,1] ## [1,] 17.63659 ## ##$pval
##              [,1]
## [1,] 0.0001480003
AST.gen(YMat=Y,UVec=c(1,0,0),GammaUMat=matrix(c(0,1,0,0,0,1),nrow=3),Stat=4)
## $Tn ## [,1] ## [1,] 17.63659 ## ##$pval
##              [,1]
## [1,] 0.0001480003