This is my first post to the mailing list and I guess it's a pretty stupid question but I can't figure it out. I hope this is the right forum for these kind of questions. Before I started using R I was using STATA to run a Wilcoxon signed-rank test on two variables. See data below: https://spreadsheets.google.com/pub?key=0ApodAA2GAEP_dDZkdzZHSFBqX1JHOWJBX1dMQUZCVkE&hl=en&output=html<%20%20https://spreadsheets.google.com/pub?key=0ApodAA2GAEP_dDZkdzZHSFBqX1JHOWJBX1dMQUZCVkE&hl=en&output=html> STATA Output: . signrank x=y Wilcoxon signed-rank test sign | obs sum ranks expected -------------+--------------------------------- positive | 41 3101 2330.5 negative | 18 1560 2330.5 zero | 49 1225 1225 -------------+--------------------------------- all | 108 5886 5886 unadjusted variance 106438.50 adjustment for ties -282.38 adjustment for zeros -10106.25 ---------- adjusted variance 96049.88 Ho: transfer_2_a = transfer_2_b z = 2.486 Prob > |z| = *0.0129* When running a Wilcoxon signed-rank test> wilcox.test(datablatt$x, datablatt$y)Wilcoxon rank sum test with continuity correction data: datablatt$x and datablatt$y W = 7059.5, p-value = *0.09197* alternative hypothesis: true location shift is not equal to 0 As you can see the p Values are different (one with H0 rejection and the other one not). I tested whether it could be that the STATA one isn't paired but this doesn't seem to be the problem. I'm dumbfound what could lead to such a difference. I couldn't find any seetings I have missed but I somehow I guess I'm using the function in the wrong way... Any ideas? Thanks a lot in advance! [[alternative HTML version deleted]]
Alain Guillet
2010-Aug-09 13:03 UTC
[R] Difference Between R: wilcox.test and STATA: signrank
Hi, Look at the output of the test made in R and you can see it is a Wilcoxon rank sum test and not a Wilcoxon signed rank test. If there are ties, I know I prefer wilcox.exact from the exactRankTests. Alain On 09-Aug-10 12:43, Capasia wrote:> This is my first post to the mailing list and I guess it's a pretty stupid > question but I can't figure it out. I hope this is the right forum for these > kind of questions. > > Before I started using R I was using STATA to run a Wilcoxon signed-rank > test on two variables. See data below: > > https://spreadsheets.google.com/pub?key=0ApodAA2GAEP_dDZkdzZHSFBqX1JHOWJBX1dMQUZCVkE&hl=en&output=html<%20%20https://spreadsheets.google.com/pub?key=0ApodAA2GAEP_dDZkdzZHSFBqX1JHOWJBX1dMQUZCVkE&hl=en&output=html> > > STATA Output: > . signrank x=y > > Wilcoxon signed-rank test > > sign | obs sum ranks expected > -------------+--------------------------------- > positive | 41 3101 2330.5 > negative | 18 1560 2330.5 > zero | 49 1225 1225 > -------------+--------------------------------- > all | 108 5886 5886 > > unadjusted variance 106438.50 > adjustment for ties -282.38 > adjustment for zeros -10106.25 > ---------- > adjusted variance 96049.88 > > Ho: transfer_2_a = transfer_2_b > z = 2.486 > Prob> |z| = *0.0129* > > When running a Wilcoxon signed-rank test > > >> wilcox.test(datablatt$x, datablatt$y) > Wilcoxon rank sum test with continuity correction > > data: datablatt$x and datablatt$y > W = 7059.5, p-value = *0.09197* > alternative hypothesis: true location shift is not equal to 0 > > As you can see the p Values are different (one with H0 rejection and the > other one not). I tested whether it could be that the STATA one isn't paired > but this doesn't seem to be the problem. > > I'm dumbfound what could lead to such a difference. I couldn't find any > seetings I have missed but I somehow I guess I'm using the function in the > wrong way... > Any ideas? > Thanks a lot in advance! > > [[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. >-- Alain Guillet Statistician and Computer Scientist SMCS - IMMAQ - Universit? catholique de Louvain Bureau c.316 Voie du Roman Pays, 20 B-1348 Louvain-la-Neuve Belgium tel: +32 10 47 30 50