In this vignette, we will briefly describe and motivate how we
constructed the test statistics used by the function m_test
and how it derives a test decision.
For a more detailed description of the asymptotic behaviour of M-estimators, we refer to Maronna et al. (2019, p. 37ff.), which is the main reference for the following motivation.
We consider two independent samples X1, …, Xm and Y1, …, Yn of i.i.d. random variables which are symmetrically distributed with variances σX2 and σY2.
For M-estimators μ̂X and μ̂Y with a ψ-function ψ, it can be shown under these conditions that
where μX ∈ ℝ and μY ∈ ℝ are the values for which
and
From this, it follows that
implying
In order to use this statistic as a test statistic for our M-tests, we need to estimate σX, σY, νX, and νY. We use the τ-scale estimator (Maronna and Zamar, 2002) to estimate σX2 and σY2 by σ̂X2 and σ̂Y2 robustly and estimate νX and νY by
Under the previous considerations, the test statistic of the M-tests we implemented in the package is given by
where Δ = μX − μY is the location difference between both distributions.
The M-tests are implemented in the function m_test
. More
details on the usage of the function can be found in the vignette Getting started with robnptests
.
Inside m_test
, we use the function scaleTau2
from the R
package robustbase
(Maechler et al., 2022) to compute the
τ-scale estimates for the
samples.
The following figure shows the simulated test sizes from a small simulation study with 1000 replications, where we applied the M-tests with different ψ-functions to samples from the 𝒩(0, 1)-distribution, the t2-distribution, and the χ32-distribution. We chose the significance level α = 0.05. The results are shown in the following figure.
Under the 𝒩(0, 1)- and the t2-distribution we make similar observations: For equal sample sizes m = n ≥ 30, the simulated test size is quite close to the the specified value of α. When m ≠ n, it seems to be important that both values are rather large and do not deviate too much from each other. Otherwise, the tests may become very anti-conservative. In general, the three test statistics lead to similar results for the considered sample sizes.
Under the χ32-distribution, all tests are anti-conservative. While there seems to be some improvement when the sample sizes become larger, the estimated sizes are still rather far away from 0.05. A reason might be that the asymptotic variance we use is only a good approximation for symmetric distributions (Maronna et al., 2019, p. 38).
Based on these results, we discourage using the tests for asymmetric distributions. For symmetric distributions, the asymptotic test should only be used for large samples. In all other cases, the randomization or permutation test might be preferable.
library(robnptests)
sessionInfo()
#> R version 4.4.2 (2024-10-31)
#> Platform: x86_64-pc-linux-gnu
#> Running under: Ubuntu 24.04.2 LTS
#>
#> Matrix products: default
#> BLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3
#> LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.26.so; LAPACK version 3.12.0
#>
#> locale:
#> [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C
#> [3] LC_TIME=en_US.UTF-8 LC_COLLATE=C
#> [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8
#> [7] LC_PAPER=en_US.UTF-8 LC_NAME=C
#> [9] LC_ADDRESS=C LC_TELEPHONE=C
#> [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
#>
#> time zone: Etc/UTC
#> tzcode source: system (glibc)
#>
#> attached base packages:
#> [1] stats graphics grDevices utils datasets methods base
#>
#> other attached packages:
#> [1] robnptests_1.1.0 rmarkdown_2.29
#>
#> loaded via a namespace (and not attached):
#> [1] digest_0.6.37 R6_2.6.1 codetools_0.2-20 fastmap_1.2.0
#> [5] xfun_0.51 maketools_1.3.2 cachem_1.1.0 knitr_1.49
#> [9] htmltools_0.5.8.1 buildtools_1.0.0 lifecycle_1.0.4 Rdpack_2.6.2
#> [13] cli_3.6.4 sass_0.4.9 jquerylib_0.1.4 compiler_4.4.2
#> [17] rbibutils_2.3 sys_3.4.3 tools_4.4.2 evaluate_1.0.3
#> [21] bslib_0.9.0 yaml_2.3.10 jsonlite_1.9.0 rlang_1.1.5