bws_cdf {BWStest} R Documentation

## CDF of the Baumgartner-Weiss-Schindler test under the null.

### Description

Computes the CDF of the Baumgartner-Weiss-Schindler test statistic under the null hypothesis of equal distributions.

### Usage

bws_cdf(b, maxj = 5L, lower_tail = TRUE)


### Arguments

 b a vector of BWS test statistics. maxj the maximum value of j to take in the approximate computation of the CDF via equation (2.5). Baumgartner et. al. claim that a value of 3 is sufficient. lower_tail boolean, when TRUE returns Psi, otherwise compute the upper tail, 1 - Psi, which is more useful for hypothesis tests.

### Details

Given value b, computes the CDF of the BWS statistic under the null, denoted as Psi(b) by Baumgartner et al. The CDF is computed from equation (2.5) via numerical quadrature.

The expression for the CDF contains the integral

\int_0^1 \frac{1}{√{r^3 (1-r)}} \mathrm{exp}≤ft(\frac{rb}{8} - \frac{π^2 (4j+1)^2}{8rb}\right) \mathrm{dr}

By making the change of variables x = 2r - 1, this can be re-expressed as an integral of the form

\int_{-1}^1 \frac{1}{√{1-x^2}} f(x) \mathrm{dx},

for some function f(x) involving b and j. This integral can be approximated via Gaussian quadrature using Chebyshev nodes (of the first kind), which is the approach we take here.

### Value

A vector of the CDF of b, Psi(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_stat, bws_test

### Examples


# do it 500 times
set.seed(123)
bvals <- replicate(500, bws_stat(rnorm(50),rnorm(50)))
pvals <- bws_cdf(bvals)
# these should be uniform!
## Not run:
plot(ecdf(pvals))

## End(Not run)

# compare to Table 1 of Baumgartner et al.
bvals <- c(1.933,2.493,3.076,3.880,4.500,5.990)
tab1v <- c(0.9,0.95,0.975,0.990,0.995,0.999)
pvals <- bws_cdf(bvals,lower_tail=TRUE)
show(data.frame(B=bvals,BWS_psi=tab1v,our_psi=pvals))



[Package BWStest version 0.2.2 Index]