Package 'abwm'

Title: Ansari-Bradley Test with Arbitrarily Missing Data
Description: Performs the two-sample Ansari–Bradley test (Ansari & Bradley, 1960 <https://www.jstor.org/stable/2237814>) for univariate, distinct data in the presence of missing values, as described in Zeng et al. (2025) <doi:10.48550/arXiv.2509.20332>. This method does not make any assumptions about the missingness mechanisms and controls the Type I error regardless of the missing values by taking all possible missing values into account.
Authors: Yijin Zeng [aut, cre]
Maintainer: Yijin Zeng <[email protected]>
License: MIT + file LICENSE
Version: 0.1.0
Built: 2026-06-05 08:54:41 UTC
Source: https://github.com/yijin-zeng/abwm

Help Index


Ansari-Bradley Test with Arbitrarily Missing Data

Description

Performs the two-sample Ansari-Bradley test for univariate, distinct data in the presence of missing values with controlled Type I error.

Usage

abwm.test(X, Y, alternative = c("two.sided", "less", "greater"))

Arguments

X, Y

numeric vectors of data values with potential missing data. Inf and -Inf values will be omitted.

alternative

a character string specifying the alternative hypothesis, must be one of "two.sided" (default), "greater" or "less". You can specify just the initial letter.

Details

abwm.test() performs the Ansari-Bradley scale testing method (Ansari & Bradley, 1960) in the presence of missing data, as described in Zeng et al. (2025). Suppose X={x1,,xn}X = \{x_{1}, \ldots, x_{n}\} and Y={y1,,ym}Y = \{y_{1}, \ldots, y_{m}\}, the Ansari-Bradley test statistic in Zeng et al. (2025) is defined as

i=1nR(xi,XY)n+m+12,\sum_{i = 1}^{n} \left|R(x_i, X \cup Y) - \frac{n + m + 1}{2}\right|,

where R(xi,XY)R(x_i, X \cup Y) denotes the rank of xix_i in the set XYX \cup Y. The function abwm.test() returns the tight bounds of the Ansari-Bradley test statistic and its p-value obtained using the normal approximation. The p-value of the test method proposed in Zeng et al. (2025) is then returned as the maximum possible p-value of the Ansari-Bradley test. This method (Zeng et al., 2025) does not make any missing data assumptions, and controls the Type I error regardless of the values of missing data.

Value

p.value

the p-value for the test.

bounds.statistic

bounds of the value of the Ansari-Bradley test statistic.

bounds.pvalue

bounds of the p-value of the Ansari-Bradley test.

alternative

a character string describing the alternative hypothesis.

data.name

a character string giving the names of the data.

References

  • Y. Zeng, N. M. Adams, D. A. Bodenham. Scale two-sample testing with arbitrarily missing data. arXiv preprint arXiv:2509.20332. 2025.

  • A. R. Ansari, R. A. Bradley. Rank-Sum Tests for Dispersions. The Annals of Mathematical Statistics, pages 1174–1189, 1960.

See Also

stats::ansari.test() when data are completely observed.

Examples

#### Assume all values are distinct.
X <- c(6.2, 3.5, NA, 7.6, 9.2)
Y <- c(0.2, 1.3, -0.5, -1.7)

## Perform the two-sided Ansari-Bradley testing with missing data.
abwm.test(X, Y, alternative = 'two.sided')

## Consider one-sided testing.
abwm.test(X, Y, alternative = 'less')