[R] the wilcox.test() and pairwise.wilcox.test are producing different results

arun smartpink111 at yahoo.com
Fri Nov 29 20:29:17 CET 2013


Hi,

Have you tried p.adjust="none"

 pairwise.wilcox.test(daily_long$value,daily_long$variable, paired=T,p.adj="none") 


pairwise.wilcox.test(Ozone, Month, p.adj = "none")
A.K.


Dear list member,
 
I want to compare if
the rank order is significantly different for seven different measures. So we
have same sample but different measures which reduces the problem to a paired
one sample Wilcox test if I understood the test correctly. In constructed toy examples
for my sake of understanding, but things are not adding up. Basically, the wilcox.test()
and pairwise.wilcox.test are producing different results when they should not
(according to my understanding of course):
 
#take a vector
daily.intake <-
c(5260,5470,5640,6180,6390,6515,
                  + 6805,7515,7515,8230,8770)
 
#I get desired results
when I do the following
daily<-data.frame(pre=daily.intake,
post=daily.intake)
 
#add som differences
daily[1,1]<-5000
daily[2,1]<-5100
 
 
#reshape the data for
pairwise comparison
library(reshape2)
daily_long<-melt(daily,
id=) 
 
#conduct simple test
wilcox.test(daily$pre,daily$post,
paired=T) #produces desired results
 
#do the test again but
now in a pairwise, which produces the same p-value as in the simple test above
pairwise.wilcox.test(daily_long$value,daily_long$variable,
paired=T) 
 
#But now I the issues
arise when testing more than two vectors.
 
#take three
vectors this time
daily<-data.frame(pre=daily.intake,
post=daily.intake, posttwo=daily.intake)
 
#add some differences
daily[1,1]<-5000
daily[2,1]<-5100
daily[10,3]<-9000
daily[11,3]<-9100
 
#the wilcox.test()
produces a set of p-values 
wilcox.test(daily$pre,daily$posttwo,
paired=T)
 wilcox.test(daily$pre,daily$post, paired=T) 
wilcox.test(daily$post,daily$posttwo,
paired=T) 
 
#and the
pairwise.wilcox.test produces another set
pairwise.wilcox.test(daily_long$value,daily_long$variable,
paired=T) 
 
 
 
##And from the manual
for pairwise.wilcox we get similar issues
 
#produces a given set
of p-values
attach(airquality)
Month <- factor(Month, labels =
month.abb[5:9])
## These give warnings because of ties :
pairwise.wilcox.test(Ozone, Month)
pairwise.wilcox.test(Ozone, Month, p.adj =
"bonf")
detach()
 
#but if we want to test the rank difference between
the 6th and 7th month we get a p-value of 0.5775
 
testar skillnaden mellan 6e och 7e månaden – observ
however that this data is not paired which makes it different to the example I
gave above.
#p-värdet är 0.5775
 
air<-subset(airquality,
airquality$Month < 7)
 
#p-value is now 0.1925
wilcox.test(air$Ozone~air$Month)
 
 
What am I doing wrong
here? 
Best
Adel
-- 
Adel Daoud, PhD
Visiting researcher
(post-doc)


Max Planck Institute for the Study of Societies / Max-Planck-Institut für
Gesellschaftsforschung
Paulstr. 3 | 506 76 Köln | Germany
Tel.: + 49 (0) 221 2767-534
[hidden email]
 Department of
Sociology and Work Science,  University of Gothenburg
Box 720
405 30 Göteborg, Sweden
Visiting address: Sprängkullsgatan 25, room K109
+46 031-786 41 73
[hidden email]



More information about the R-help mailing list