W Bradley Knox
2014-Sep-03 00:54 UTC
[R] wilcox.test - difference between p-values of R and online calculators
Hi. I'm taking the long-overdue step of moving from using online calculators to compute results for Mann-Whitney U tests to a more streamlined system involving R. However, I'm finding that R computes a different result than the 3 online calculators that I've used before (all of which approximately agree). These calculators are here: http://elegans.som.vcu.edu/~leon/stats/utest.cgi http://vassarstats.net/utest.html http://www.socscistatistics.com/tests/mannwhitney/ An example calculation is *wilcox.test(c(359,359,359,359,359,359,335,359,359,359,359,359,359,359,359,359,359,359,359,359,359,303,359,359,359),c(332,85,359,359,359,220,231,300,359,237,359,183,286,355,250,105,359,359,298,359,359,359,28.6,359,359,128))* which prints *Wilcoxon rank sum test with continuity correction data: c(359, 359, 359, 359, 359, 359, 335, 359, 359, 359, 359, 359, and c(332, 85, 359, 359, 359, 220, 231, 300, 359, 237, 359, 183, 359, 359, 359, 359, 359, 359, 359, 359, 359, 303, 359, 359, and 286, 355, 250, 105, 359, 359, 298, 359, 359, 359, 28.6, 359, 359) and 359, 128) W = 485, p-value = 0.0002594 alternative hypothesis: true location shift is not equal to 0 Warning message: In wilcox.test.default(c(359, 359, 359, 359, 359, 359, 335, 359, : cannot compute exact p-value with ties* However, all of the online calculators find p-values close to 0.0025, 10x the value output by R. All results are for a two-tailed case. Importantly, the W value computed by R *does agree* with the U values output by the first two online calculators listed above, yet it has a different p-value. Can anyone shed some light on how and why R's calculation differs from that of these online calculators? Thanks for your time. ____________________ W. Bradley Knox, PhD http://bradknox.net bradknox at mit.edu [[alternative HTML version deleted]]
Tal Galili
2014-Sep-03 10:23 UTC
[R] wilcox.test - difference between p-values of R and online calculators
It seems your numbers has ties. What happens if you run wilcox.test with correct=FALSE, will the results be the same as the online calculators? ----------------Contact Details:------------------------------------------------------- Contact me: Tal.Galili at gmail.com | Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) | www.r-statistics.com (English) ---------------------------------------------------------------------------------------------- On Wed, Sep 3, 2014 at 3:54 AM, W Bradley Knox <bradknox at mit.edu> wrote:> Hi. > > I'm taking the long-overdue step of moving from using online calculators to > compute results for Mann-Whitney U tests to a more streamlined system > involving R. > > However, I'm finding that R computes a different result than the 3 online > calculators that I've used before (all of which approximately agree). These > calculators are here: > > http://elegans.som.vcu.edu/~leon/stats/utest.cgi > http://vassarstats.net/utest.html > http://www.socscistatistics.com/tests/mannwhitney/ > > An example calculation is > > > *wilcox.test(c(359,359,359,359,359,359,335,359,359,359,359,359,359,359,359,359,359,359,359,359,359,303,359,359,359),c(332,85,359,359,359,220,231,300,359,237,359,183,286,355,250,105,359,359,298,359,359,359,28.6,359,359,128))* > > which prints > > > > > > > > > > *Wilcoxon rank sum test with continuity correction data: c(359, 359, 359, > 359, 359, 359, 335, 359, 359, 359, 359, 359, and c(332, 85, 359, 359, 359, > 220, 231, 300, 359, 237, 359, 183, 359, 359, 359, 359, 359, 359, 359, 359, > 359, 303, 359, 359, and 286, 355, 250, 105, 359, 359, 298, 359, 359, 359, > 28.6, 359, 359) and 359, 128) W = 485, p-value = 0.0002594 alternative > hypothesis: true location shift is not equal to 0 Warning message: In > wilcox.test.default(c(359, 359, 359, 359, 359, 359, 335, 359, : cannot > compute exact p-value with ties* > > > However, all of the online calculators find p-values close to 0.0025, 10x > the value output by R. All results are for a two-tailed case. Importantly, > the W value computed by R *does agree* with the U values output by the > first two online calculators listed above, yet it has a different p-value. > > Can anyone shed some light on how and why R's calculation differs from that > of these online calculators? Thanks for your time. > > ____________________ > W. Bradley Knox, PhD > http://bradknox.net > bradknox at mit.edu > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >[[alternative HTML version deleted]]