Test the hypothesis that median is zero using Wilcoxon rank sum test

A random sample of seven boys was selected from a group of boys in a senior class who lived on farms. Another random sample of nine boys was selected from a group of boys in the same class who lived in town. A test was devised and given to these sixteen boys to see whether farm boys in general were more physically fit than town boys. The scores of the farm boys (Xi) and the town boys (Yi) are as follows:

$$X_i = {14.8,5.6, 9, 10.6, 12.9, 11.4, 2.7}$$

$$Y_i = {2.4, 7.9, 10.6, 9.1, 10.6, 5.0, 18.6, 5.6, 4}$$

Carry out a Wilcoxon test of the hypothesis that there is no difference in the physical fitness of farm boys and town boys.

After reordering: I have that (T for town, F for farm)

2.4 2.7 4 5 5.6 5.6 7.9 9 9.1 10.6 10.6 10.6 11.4 12.9 14.8 18.6
category T F T T T F T F T T T F F F F T
rank 1 2 3 4 5.5 5.5 7 8 9 11 11 11 13 14 15 16

Hence $$W_{7+9} = \sum iZ_i = 67.5 \text{ or } 68.5$$ as the sum of all rank is 136

Then I ran into 2 problems when using the normal distribution (and the mid rank approach) to approximate:

the formula $$Z = \frac{W-(m)(m+n+1)/2}{\sqrt{\frac{mn}{12}(m+n+1-\frac{\sum (t^3-t)}{(m+n)(m+n-1)} )}}$$

first of all, the mu calculated in the formula is $$7*17/2=59.5$$ doesn't correspond to the mean of all the possible rank (i.e. 136/2 = 68) this then leads to $$Z(W =67.5)=0.85 \neq Z(W=68.5)=0.96$$. This contradicts the fact that normal is suppose to be symmetric. (Also as seen in the probability table for Wilcoxon rank sum distribution). And the answer provided states that $$Z \approx 0.9031$$ (Which after checking, is Z(W = 68)). Hence we accept $$H_0$$ that there is no difference.

So why is the mean in the formula calculated such that it is not symmetric? why is Z calced at W = 68?

Here is your data in R, with the nonparametric two-sample Wilcoxon signed-rank test:

farm
[1] 14.8  5.6  9.0 10.6 12.9 11.4  2.7
town
[1]  2.4  7.9 10.6  9.1 10.6  5.0 18.6  5.6  4.0

wilcox.test(town,farm)

Wilcoxon rank sum test with continuity correction

data:  town and farm
W = 22.5, p-value = 0.3665
alternative hypothesis:
true location shift is not equal to 0

Warning message:
In wilcox.test.default(town, farm) :
cannot compute exact p-value with ties


There are two difficulties with your data: (1) There are ties, so that modifications of the usual formulas need to be made. Various authors and statistical computer programs use slightly different modifications. (2) Seven is near the bare minimum sample size necessary to find a significant difference at the 5% level, no matter what the scores may be.

Because of ties, notice that ranks are not all integers, Also, the sum of the ranks from R is 136, so I am having trouble following your computations.

rank(c(farm,town))
[1] 15.0  5.5  8.0 11.0 14.0 13.0  2.0  1.0  7.0 11.0  9.0
[12] 11.0  4.0 16.0  5.5  3.0
sort(rank(c(farm,town)))
[1]  1.0  2.0  3.0  4.0  5.5  5.5  7.0  8.0  9.0 11.0 11.0
[12] 11.0 13.0 14.0 15.0 16.0
sum(rank(c(farm,town)))
[1] 136
sum(1:(7+9))
[1] 136


The Wilcoxon signed rank test is equivalent to the Mann-Whitney U test, even though the two versions of the test use different statistics (one a simple transformation of the other). So you may be confusing the slightly different computational details between the two versions.

Finally, your two datasets are really too small formally to test for normality, but neither fails a Shapiro-Wilk test for normality. Moreover, their normal probability plots seem consistent with normal data. So I am wondering why you are doing a nonparametric test instead of a t test (which also fails to reject the null hypothesis that the samples have different centers).