Strecker, Stefan
2003-Feb-15 12:50 UTC
[R] How to code a bootstrap version of the Wilcoxon-Mann-Whitney test (and variants)?
Hello, can someone please help me with coding a function for a bootstrap WMW test (package boot, R under Windows, version 1.6.2)?
Torsten Hothorn
2003-Feb-17 18:46 UTC
[R] How to code a bootstrap version of the Wilcoxon-Mann-Whitneytest (and variants)?
> 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 > >
Thomas Lumley
2003-Feb-17 19:49 UTC
[R] How to code a bootstrap version of the Wilcoxon-Mann-Whitneytest (and variants)?
On Mon, 17 Feb 2003, Torsten Hothorn wrote:> 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. >One could be interested in a bootstrap estimate of the sampling distribution of the test statistic. This is only the same as the permutation distribution if the two distributions are the same. You can certainly have the level of the test equal to the power without the distributions being the same; whether this counts as part of the null hypothesis is really a philosophical question. -thomas
Apparently Analagous Threads
- Wilcoxon Mann-Whitney Rank Sum Test in R
- How to code a bootstrap version of the Wilcoxon-Mann-Whitney test?
- Mann-Whitney & Wilcoxon Rank Sum
- Wilcoxon-Mann-Whitney U value: outcomes from different stat packages
- Interpreting the result of a Wilcoxon (Mann-Whitney U) test