0

I am trying to compare two groups using Wilcox.test() function in R. The test works fine but there is something weird about the 95% confidence interval for the location shift parameter. It doesn't contain the estimate, what could be the reason?

Here is a part of the data to reproduce the issue.

    Group        y
1       B 0.18181818
2       D 0.00000000
3       B 0.09090909
4       D 0.00000000
5       B 0.00000000
6       D 0.00000000
7       B 0.09090909
8       D 0.00000000
9       B 0.00000000
10      D 0.00000000
11      B 0.00000000
12      D 0.00000000
13      B 0.00000000
14      B 0.00000000
15      D 0.15384615
16      B 0.00000000
17      D 0.04000000
18      B 0.00000000
19      D 0.00000000
20      B 0.11111111
21      D 0.03846154
22      B 0.18181818
23      D 0.07692308
24      B 0.04545455
25      D 0.08333333
26      B 0.00000000
27      D 0.00000000
28      D 0.00000000
29      B 0.00000000
30      D 0.04761905
31      B 0.00000000
32      D 0.08695652
33      B 0.00000000
34      D 0.00000000
35      B 0.00000000
36      D 0.00000000
37      B 0.00000000
38      D 0.00000000
39      B 0.04109589
40      D 0.19402985
41      B 0.06410256
42      D 0.08955224
43      B 0.00000000
44      D 0.01492537
45      B 0.00000000
46      D 0.04477612
47      B 0.01369863
48      D 0.05970149
49      B 0.09589041
50      D 0.05970149
51      B 0.01369863
52      D 0.00000000
53      B 0.03797468
54      D 0.02985075
55      B 0.00000000
56      D 0.01492537
57      B 0.08974359
58      D 0.05970149
59      B 0.02325581
60      D 0.06060606
61      B 0.16279070
62      D 0.00000000
63      B 0.00000000
64      D 0.02857143
65      B 0.04651163
66      D 0.03846154
67      B 0.02325581
68      D 0.07692308
69      B 0.00000000
70      D 0.00000000
71      D 0.01923077
72      B 0.02325581
73      D 0.21568627
74      B 0.02325581
75      D 0.00000000
76      B 0.10389610
77      D 0.06250000
78      B 0.00000000
79      D 0.04761905
80      B 0.01428571
81      D 0.06250000
82      B 0.00000000
83      D 0.00000000
84      B 0.00000000
85      D 0.01818182
86      B 0.01298701
87      D 0.06250000
88      B 0.02173913
89      D 0.06250000
90      B 0.00000000
91      D 0.00000000
92      B 0.01298701
93      D 0.04687500
94      B 0.03125000
95      D 0.02272727
96      B 0.05714286
97      D 0.07812500
98      D 0.00000000
99      B 0.02666667
100     D 0.05000000
101     B 0.00000000
102     D 0.09523810
103     B 0.00000000
104     D 0.01449275
105     B 0.00000000
106     D 0.04347826
107     B 0.05555556
108     D 0.00000000
109     B 0.05555556
110     D 0.00000000
111     B 0.13636364
112     D 0.00000000
113     B 0.00000000
114     D 0.00000000
115     B 0.04545455
116     D 0.50000000
117     B 0.00000000
118     D 0.00000000
119     B 0.05555556
120     D 0.50000000
121     B 0.00000000
122     D 0.50000000
123     B 0.04545455
124     D 0.00000000
125     B 0.00000000
126     D 0.00000000
127     B 0.16000000
128     D 0.00000000
129     B 0.08000000
130     D 0.00000000
131     B 0.08000000
132     D 0.00000000
133     B 0.00000000
134     D 0.40000000
135     B 0.04000000
136     D 0.00000000
137     B 0.12000000
138     D 0.20000000
139     B 0.16000000
140     B 0.00000000
141     B 0.06896552
142     B 0.10344828
143     D 0.14285714
144     B 0.00000000
145     D 0.00000000
146     B 0.31034483
147     D 0.00000000
148     B 0.08695652
149     D 0.00000000
150     B 0.03448276
151     D 0.12500000
152     B 0.03448276
153     B 0.00000000
154     D 0.00000000
155     B 0.03448276
156     D 0.00000000
157     B 0.10714286
158     D 0.12500000
159     B 0.10526316
160     D 0.00000000
161     B 0.00000000
162     D 0.66666667
163     B 0.00000000
164     D 0.00000000
165     B 0.13333333
166     D 0.00000000
167     B 0.00000000
168     B 0.00000000
169     D 0.00000000
170     B 0.12500000
171     B 0.00000000
172     B 0.00000000
173     B 0.25000000
174     B 0.37500000
175     B 0.00000000
176     B 0.37500000
177     B 0.25000000
178     B 0.00000000
179     B 0.00000000
180     B 0.25000000
181     B 0.00000000
182     B 0.12500000
183     B 0.00000000
184     B 0.85714286
185     B 0.07142857
186     B 0.07142857
187     B 0.00000000
188     B 0.00000000
189     B 0.00000000
190     B 0.00000000
191     B 0.06666667
192     B 0.00000000
193     B 0.00000000
194     B 0.13333333
195     B 0.09523810
196     B 0.00000000
197     B 0.00000000
198     B 0.09523810
199     B 0.00000000
200     B 0.00000000
201     B 0.09523810
202     B 0.14285714
203     B 0.23809524
204     B 0.03703704
205     B 0.10526316
206     B 0.00000000
207     B 0.33333333
208     B 0.20000000
209     B 0.20000000
210     B 0.00000000
211     B 0.22727273
212     B 0.00000000
213     B 0.00000000
214     B 0.00000000
215     B 0.00000000
216     B 0.04000000
217     B 0.00000000
218     B 0.00000000
219     B 0.00000000

Here is is my code

wilcox.test(y~Group,data=ds,conf.int=T)

Then I get the following output from the code

    Wilcoxon rank sum test with continuity correction

data:  y by Group
W = 5817, p-value = 0.6892
alternative hypothesis: true location shift is not equal to 0
95 percent confidence interval:
 -1.284460e-05  2.162369e-06
sample estimates:
difference in location 
          4.911307e-05 
  • And what is your code? – Limey Aug 23 '22 at 07:29
  • From the online doc: "Note that in the two-sample case the estimator for the difference in location parameters does not estimate the difference in medians (a common misconception) but rather the median of the difference between a sample from x and a sample from y." Also, the p-value is based on a Normal approximation, the CI is non-parametric CI. There is no reason why they should agree in every case. – Limey Aug 23 '22 at 07:41
  • @Limey I edited the question to include my code. I have no problem with the p.value disagreeing with the confidence interval. I also understand that the location shift estimate is the Hodges-Lehmann Estimate. my problem is: that the lower bound of the confidence here is -1.284460e-05, and the upper bound is 2.162369e-06. but the estimate is 4.911307e-05. It is weird that 4.911307e-05 is outside the interval [-1.284460e-05 ,2.162369e-06] – mutinda festus Aug 23 '22 at 08:12

0 Answers0