Talking about rounding errors, I have found what I think it is a bug in
the way Stata manages sometimes tied differences before ranking them for
Wilcoxon's signed ranks test.
I used this example for many years in my classes, both with hand
calculations and SPSS as statistical package (the one we had until
recently at my University). When I use Stata instead to test if the
population median is 0.6, I get different results:
. signrank cobre = 0.6
Wilcoxon signed-rank test
sign | obs sum ranks expected
-------------+---------------------------------
positive | 28 591.5 410
negative | 12 228.5 410
zero | 0 0 0
-------------+---------------------------------
all | 40 820 820
unadjusted variance 5535.00
adjustment for ties -0.75
adjustment for zeros 0.00
----------
adjusted variance 5534.25
Ho: cobre = 0.6
z = 2.440
Prob > |z| = 0.0147
SPSS (and I get the same result by hand)gives:
Ranks
N Mean Rank Sum of Ranks
Negative Ranks 28 21.00 588.00
Positive Ranks 12 19.33 232.00
Zero 0
Total 40
Test Statistics
Z -2.393
Asymp. Sig. (2-tailed) 0.017
As you can see, the rank sum (and, therefore, the Z statistic) are different
After a bit of experimenting, I have found that Stata is handling tied
differences involving opposite signs in a wrong way, but not
systematically. The last column (rank~100) has the correct ranks, while
ranked" contains the same values that Stata uses to get the positive and
negative sum of ranks. Notice the difference for cases 5/6/7, 18/19,
22/23/24, 29/30, 32/33. In all cases, the wrong ranking involves
differences with oppsotie signs, but this is not systematic (see cases
1/2, where the ties are recognized, or 11/12, 13/14...). I used "double"
in all the generated variables to avoid the known float problems.