Worked example I
We take for our first example part of a study by Farkas et al (2001) on the role of Helicobacter pylori infection in hereditary angioneurotic oedema. 19 of 65 patients had H. pylori infection.
The infection was successfully eradicated using combination therapy in 18 of these patients. The impact of eradication was studied in detail in nine of these patients  the data below show the number of episodes in these nine patients over (a median of) 10 months pretreatment and 10 months post eradication .
Number of oedematous episodes in patients with hereditary angioneurotic oedema 
Patient number 
Pre treatment 
Post treatment 
Difference (d) 
Rank 
Signed rank (R_{i}) 
1 2 3 4 5 6 7 8 9 
13 11 6 14 6 15 13 14 8 
1 2 1 1 3 3 2 4 2 
12 9 5 13 3 12 11 10 6 
7.5 4 2 9 1 7.5 6 5 3 
+ 7.5 + 4 + 2 + 9 + 1 + 7.5 + 6 + 5 + 3 
Sum +ve ranks      45 
Sum ve ranks      0 
We first examine the distribution of differences to check whether it is symmetrical. This is obviously difficult with such a small sample, but an obviously skewed distribution might give us rather less confidence in our result.
{Fig. 1}
The distribution is clearly not symmetrical, although one could argue that it is not strongly skewed, and that the irregularities simply result from small sample size. We will continue with this test, but bear in mind that conclusions based on a borderline Pvalue would be unsafe.
Exact method
Given we have a small number of observations, we should use an exact method rather than the normal approximation. S+ and S^{−} are 45 and 0 respectively.
Using tables we find that the critical value for n = 9 at P = 0.005 is 2. Since S^{−} is less than this we might be tempted to accept the difference as significant at P < 0.005. However, this result is unreliable because the table values are only accurate if there are no ties.
Using
If we have the exact Wilcoxon test which is available in a separate package in R, we can still obtain the correct Pvalue. This is 0.0039, as quoted by the author of the paper. The estimate of the median difference is 8.75 (95% CI: 5.5  12.0). We may conclude that that there was a significant decline in the number of oedematous episodes post treatment.
Normal approximation method
If we did not have the option of doing an exact test which will accept ties , we would have to use the second formulation above
z
 = 
45 
= 
2.6679 

√{7.5^{2} + 4^{2}....+ 3^{2})

This gives a twotailed Pvalue of 0.007633.
Using
Using R with the Wilcoxon test in the standard statistics package gives the same value. It may seem surprising that the normal approximation test is more liberal than the exact test. This is most likely because the sample size is so small that the normal approximation is unreliable..
Exact confidence limits
To obtain the HodgesLehmann estimate of the median difference and its 95% confidence interval, we first arrange the differences (d) from the table above in order:
3 5 6 9 10 11 12 12 13
We then construct a triangular matrix of the Walsh averages, a task most easily achieved in R. The median difference is given by the median of these values which is 9.0. The required number of averages from each end of the array to obtain the (approximate) upper and lower confidence limits is given by the quantile of the Wilcoxon matchedpairs signedranks statistic for n observations at P = 0.025 which is 6.
 [3]  [5]  [6]  [9]  [10]  [11]  [12]  [12]  [13]

[3]  3.0  4.0  4.5  6.0  6.5  7.0  7.5  7.5  8.0

[5]   5.0  5.5  7.0  7.5  8.0  8.5  8.5  9.0

[6]    6.0  7.5  8.0  8.5  9.0  9.0  9.5

[9]     9.0  9.5  10.0  10.5  10.5  11.0

[10]      10.0  10.5  11.0  11.0  11.5

[11]       11.0  11.5  11.5  12.0

[12]        12.0  12.0  12.5

[12]         12.0  12.5

[13]          13.0 
The 5 highest values in this array are shown in turquoise cells  the 6th is in a red cell and is the upper 95% confidence limit. The 5 lowest values in the array are shown in green cells  the 6th is in a red cell and is the lower 95% confidence limit. We conclude that the 95% confidence interval for the difference is 6 to 12. This interval does not overlap zero in agreement with our earlier significant Pvalue of 0.0076.
Whilst this study gave us a manageable worked example, the sample size is really too small for the normal approximation.