bws_stat {BWStest} R Documentation

Compute the test statistic of the Baumgartner-Weiss-Schindler test.

Description

Compute the Baumgartner-Weiss-Schindler test statistic.

Usage

bws_stat(x, y)


Arguments

 x a vector. y a vector.

Details

Given vectors X and Y, computes B_X and B_Y as described by Baumgartner et al., returning their average, B. The test statistic approximates the variance-weighted square norm of the difference in CDFs of the two distributions. For sufficiently large sample sizes (more than 20, say), under the null the test statistic approaches the asymptotic value computed in bws_cdf.

The test value is an approximation of

\tilde{B} = \frac{mn}{m+n} \int_0^1 \frac{1}{z(1-z)} ≤ft(F_X(z) - F_Y(z)\right)^2 \mathrm{dz},

where m (n) is the number of elements in X (Y), and F_X(z) (F_Y(z)) is the CDF of X (Y).

The test statistic is based only on the ranks of the input. If the same monotonic transform is applied to both vectors, the result should be unchanged. Moreover, the test is inherently two-sided, so swapping X and Y should also leave the test statistic unchanged.

Value

The BWS test statistic, B.

Author(s)

Steven E. Pav shabbychef@gmail.com

References

W. Baumgartner, P. Weiss, H. Schindler, 'A nonparametric test for the general two-sample problem', Biometrics 54, no. 3 (Sep., 1998): pp. 1129-1135. http://doai.io/10.2307/2533862

bws_cdf, bws_test

Examples


set.seed(1234)
x <- runif(1000)
y <- runif(100)
bval <- bws_stat(x,y)
# check a monotonic transform:
ftrans <- function(x) { log(1 + x) }
bval2 <- bws_stat(ftrans(x),ftrans(y))
stopifnot(all.equal(bval,bval2))
# check commutivity
bval3 <- bws_stat(y,x)
stopifnot(all.equal(bval,bval3))



[Package BWStest version 0.2.2 Index]