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 XX and YY, computes BXB_X and BYB_Y as described by Baumgartner et al., returning their average, BB. 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

B~=mnm+n011z(1z)(FX(z)FY(z))2dz,\tilde{B} = \frac{mn}{m+n} \int_0^1 \frac{1}{z(1-z)} \left(F_X(z) - F_Y(z)\right)^2 \mathrm{dz},

where mm (nn) is the number of elements in XX (YY), and FX(z)F_X(z) (FY(z)F_Y(z)) is the CDF of XX (YY).

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 XX and YY should also leave the test statistic unchanged.

Value

The BWS test statistic, BB.

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. doi:10.2307/2533862

See Also

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.3 Index]