many ties are present, a correction term should be included in the formula used to
calculate the p value. Let’s consider a simple problem in whi ch there are two groups
of sizes n
1
= 3 and n
2
= 4. We allot seven ranks in total, one to each of the seven
observations in both groups. If the null hypothesis is true, i.e. the population
distribution is the same for both groups, each rank number has equal probability
of being assigned to either of the two groups. The allotment of three rank numbers to
groups 1 and 4 rank numbers to group 2 can be viewed as a selection process in which
any three ranks are chosen without replacement from a set of seven ranks. The total
number of distinct combinations of two sets of ranks is C
7
3
= 35.
Suppose w e have the outcome shown in Table 4.19 from an experiment. There
are three other possible rank combinations that produce a result atleast as extreme
as this, i.e. three sets of ra nks (1, 2, 3), (1, 2, 4), and (1, 2, 5) produce a value of R
1
≤
8.
The probability of obtaining any of these four rank combinations is
4/35 = 0.1142. A two-sided hypothesis requires that this probability be doubled
since extre me observations observed in the reverse direction also lead to rejection
of the null hypothesis. For this example, the four extreme observations for group 1 in
the reverse direction are (5, 6, 7), (4, 6, 7), (3, 6, 7), and (4, 5, 7), which produce R
1
≥ 16.
The p value corresponding to the test statistic R
1
= 8 is 8/35 = 0.2286.
For the problem illustrated in Box 4.1, the total number of rank combinations
possible in both groups is C
27
11
. Calculation of all possible rank combinations that will
produce an R
1
test statistic value ≥ 194.5 is too tedious to perform by hand. Instead
we make use of statistical software to calculate the p value associated with the
calculated rank sums.
Using MATLAB
The ranksum function available in Statistics Toolbox performs the Wilcoxon rank-
sum test. The syntax is
p = ranksum(x, y)
where x and y are two vectors, not necessarily of equal length, that store the
observations of two independent samples. The p value is generated for a two-sided
hypothesis of equal population medians.
The Wilcoxon rank-sum test is mathematically equivalent to another non-parametric
statistical procedure called the Mann Whitney U test. The test procedures for either
test are slightly different but the underlying probability calculations are equivalent and
both tests yield the same p value for a given data set. The rank-sum test does not use
all the information contained in the data, i.e. the absolute magnitude of the observa-
tions are not factored into the calculation of the test statistic. Thus, this method is not
Table 4.19. Wilcoxon rank sum test
Ranks Rank sum
Group 1: 1, 3, 4 R
1
=8
Group 2: 2, 5, 6, 7 R
2
=20
298
Hypothesis testing