I get these BIZARRE results from wilcox.test() When INCREASING the number of samples i get INCREASED p-values. When increasing the number of samples further, the p-values goes down again. This seems really bizarre! Can anyone explain why this is so?! Example:> w <- wilcox.test(c(1:40),(c(1:40)+100)) > w$p.value[1] 1.860340e-23> w <- wilcox.test(c(1:50),(c(1:50)+100)) > w$p.value[1] 7.066072e-18> w <- wilcox.test(c(1:60),(c(1:60)+100)) > w$p.value[1] 3.556571e-21> w <- wilcox.test(c(1:70),(c(1:70)+100)) > w$p.value[1] 1.817156e-24 Best regards, genecleaner (R version 2.11.1 (2010-05-31), Win7) -- View this message in context: http://r.789695.n4.nabble.com/BIZARRE-results-from-wilcox-test-tp3597818p3597818.html Sent from the R help mailing list archive at Nabble.com.
The difference is so small as to be meaningless, and probably has to do with rounding error at the limits of machine precision. Really, why would you think this is either bizarre or important? Sarah On Tue, Jun 14, 2011 at 4:57 PM, genecleaner <genecleaner at gmail.com> wrote:> I get these BIZARRE results from wilcox.test() > When INCREASING the number of samples i get INCREASED p-values. When > increasing the number of samples further, the p-values goes down again. This > seems really bizarre! > > Can anyone explain why this is so?! > > > Example: > >> w <- wilcox.test(c(1:40),(c(1:40)+100)) >> w$p.value > [1] 1.860340e-23 >> w <- wilcox.test(c(1:50),(c(1:50)+100)) >> w$p.value > [1] 7.066072e-18 >> w <- wilcox.test(c(1:60),(c(1:60)+100)) >> w$p.value > [1] 3.556571e-21 >> w <- wilcox.test(c(1:70),(c(1:70)+100)) >> w$p.value > [1] 1.817156e-24 > > Best regards, > genecleaner (R version 2.11.1 (2010-05-31), Win7) > >-- Sarah Goslee http://www.functionaldiversity.org
I would argue that your Wilcoxon test is meaningless. For all four datasets, the first data column has no overlap whatsoever with the second data column. All Wilcoxon Ws are 0. The "BIZARRE" behavior may be that the test tries to interpolate what the p value for W of 0 would be given your sample size. With your sample size, the Wilcoxon test may use a normal approximation, which might explain this behavior (http://en.wikipedia.org/wiki/Mann?Whitney_U#Normal_approximation) you would have to check it yourself. If you create overlap by, say, adding the mean of the first data column to all observations in the second data column, you have overlap between the data columns. Only then it makes sense to run a Wilcoxon test and you get what you would expect. In your instance, it is nonsensical to perform a Wilcoxon test. That is the likely reason for the p-value issue you observe. w <- wilcox.test(c(1:40),(c(1:40)+20.5)) w$p.value w <- wilcox.test(c(1:50),(c(1:50)+25.5)) w$p.value w <- wilcox.test(c(1:60),(c(1:60)+30.5)) w$p.value w <- wilcox.test(c(1:70),(c(1:70)+35.5)) w$p.value -- View this message in context: http://r.789695.n4.nabble.com/BIZARRE-results-from-wilcox-test-tp3597818p3597936.html Sent from the R help mailing list archive at Nabble.com.
Dear Daniel and Sarah, Thanks you for your rude replies . The script that I provided was only an example and to illustrate the problem. It makes perfectly sense to use the Wilcoxon test on my datasets. However, you replies were nonsensical, since you could not solve the problem but rather just bullied me. Anyway, this is the solution to the problem: the exact=TRUE statement should be added> w <- wilcox.test(c(1:50),(c(1:50)+100)) > w$p.value[1] 7.066072e-18> w <- wilcox.test(c(1:50),(c(1:50)+100), exact=TRUE) > w$p.value[1] 1.982331e-29 Best regards, genecleaner -- View this message in context: http://r.789695.n4.nabble.com/BIZARRE-results-from-wilcox-test-tp3597818p3598039.html Sent from the R help mailing list archive at Nabble.com.
I did not intend to bully you but rather tried to speak narrowly to the core of the issue. In a sense the point was that the example you used to illustrate the problem created part of the problem and that in a sensical dataset you would not obtain nonsensical results. Secondly, my reply talked to the solution of your problem by pointing out that the test uses the normal approximation by standard, which is exactly that: an approximation, implying that avoiding the approximation may solve the issue. This is what exact=T does, as you figured out. Daniel genecleaner wrote:> > Dear Daniel and Sarah, > > Thanks you for your rude replies . > The script that I provided was only an example and to illustrate the > problem. It makes perfectly sense to use the Wilcoxon test on my datasets. > However, you replies were nonsensical, since you could not solve the > problem but rather just bullied me. > > Anyway, this is the solution to the problem: the exact=TRUE statement > should be added > >> w <- wilcox.test(c(1:50),(c(1:50)+100)) >> w$p.value > [1] 7.066072e-18 >> w <- wilcox.test(c(1:50),(c(1:50)+100), exact=TRUE) >> w$p.value > [1] 1.982331e-29 > > Best regards, > genecleaner >-- View this message in context: http://r.789695.n4.nabble.com/BIZARRE-results-from-wilcox-test-tp3597818p3600158.html Sent from the R help mailing list archive at Nabble.com.