Learn R Programming

abwm (version 0.1.0)

abwm.test: 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"))

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.

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 = \{x_{1}, \ldots, x_{n}\}\) and \(Y = \{y_{1}, \ldots, y_{m}\}\), the Ansari-Bradley test statistic in Zeng et al. (2025) is defined as $$\sum_{i = 1}^{n} \left|R(x_i, X \cup Y) - \frac{n + m + 1}{2}\right|,$$ where \(R(x_i, X \cup Y)\) denotes the rank of \(x_i\) in the set \(X \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.

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

Run this code
#### 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')

Run the code above in your browser using DataLab