[R] How to code a bootstrap version of the Wilcoxon-Mann-Whitneytest (and variants)?

Torsten Hothorn Torsten.Hothorn at rzmail.uni-erlangen.de
Mon Feb 17 18:46:03 CET 2003


> Hello,
>
> can someone please help me with coding a function for a bootstrap WMW test (package boot, R under Windows, version 1.6.2)?
>
> >From reading the RNews article on the boot package I understand that I have to supply the boot command with a function to calculate the test statistic but I have difficulties coding the function. Since some of the pooled samples contain many ties, I would like to code the function so that I can easily exchange the Wilcoxon W (or Mann-Whitney U) statistic with a variant (such as for example the Fligner-Policello robust rank-order test statistic or the Uleman U statistic). Is there a way to achieve this?
>

what are you interested in? The permutation distribution of (almost) any
statistic can be computed either using special functions like {dpq}wilcox (as you
already noticed) or pperm (package exactRankTests). If I recall it
correctly, there is a chapter in "MASS" on how to simulate the permutation
distribution in a fast way.

Torsten

> My samples are independent and consist of 8 observations. The values are discrete and measured on ordinal scale. I found the following example for an WMW test online but I do not know how to write a function to be supplied to the boot command:
>
> # Run Wilcoxon Exact Test
> #
> # Create X and Y variables
> x <- c(76.375, 75.125, 77, 77, 77, 76.375, 77, 76.375)
> y <- c(76.375, 75.75, 76.375, 76.375, 76.375, 75.75, 77, 76.375)
> print(nx <- length(x))
> print(ny <- length(y))
>
> data <- c(x, y)
> names(data) <- c(rep("x", nx), rep("y", ny))
> data <- sort(data)
> r <- rank(data)
>
> # Printout data and ranks in X and Y
> rbind(data, r)
>
> # Wilcoxon W statistic
> print(w <- sum(r[names(data) == "y"]))
>
> # Umrechnen in Mann-Whitney U statistic
> print(u <- w - ny * (ny + 1) / 2)
>
> # Get probability from Wilcoxon distribution m=8, n=8
> pwilcox(u, nx, ny)
>
> # Perform two-sided exact test
> wilcox.exact(y, x, alternative="two.sided")
>
>
> Thanks in advance
> Stefan
> ---
> Stefan Strecker
> Universitaet Karlsruhe (TH)
> Department of Economics and Business Engineering
> Chair for Information Management and Systems
> Englerstrasse 14
> D-76131 Karlsruhe, Germany
> T: +49 721 608 8374
> F: +49 721 608 8399
> M: +49 179 69 29 746
> http://www.iw.uni-karlsruhe.de
> DH PGP Key available upon request
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> http://www.stat.math.ethz.ch/mailman/listinfo/r-help
>
>




More information about the R-help mailing list