[R] Estimate in Wilcox_test vs wilcox.exact

Jue.Wang2 at sanofi-aventis.com Jue.Wang2 at sanofi-aventis.com
Fri Oct 6 17:47:06 CEST 2006


Does any one know why wilcox.exact sometimes doesn't agree with wilcox_test on the estimate of the difference of medians in two levels ?

Thank you
 
Jue Wang, Biostatistician
Contracted Position for Preclinical & Research Biostatistics
PrO Unlimited
(908) 231-3022


Example 1: (wilcox_test gives correct median difference)

y1<-rep(0,10)
y2<-c(32.507,61.901,134.938,49.95,29.954,99.835,49.27)
median(y1)-median(y2)

-49.95

y<-c(y1,y2)
x<-c(rep(0,10),rep(1,7))

Test<-wilcox_test(y~factor(x),distribution="exact",conf.int=TRUE)
confint(Test)$estimate

difference in location 
                -49.95 

 
exact<-wilcox.exact(y~x,conf.int=TRUE)
exact$estimate


difference in location 
              -55.9255 


Example 2: (wilcox.exact gives correct median difference)


y1<-c(0,0,0,0,0,3.065,3.075,3.075,3.118,3.118)
y2<-c(0,0,0,0,0,0,0,14.958,51.002,63.984)


median(y1)-median(y2)

1.5325

y<-c(y1,y2)
x<-c(rep(0,10),rep(1,10))
Test<-wilcox_test(y~factor(x),distribution="exact",conf.int=TRUE)
confint(Test)$estimate
difference in location 
                     0 
 
exact<-wilcox.exact(y~x,conf.int=TRUE)
exact$estimate
difference in location 
                1.5325



More information about the R-help mailing list