Mann-Whitney U Test and Wilcoxon signed rank test
Mann-Whitney U Test
The Mann-Whitney U Test is a non-parametric statistical test used to compare
two independent samples or groups. It is often employed when the data do not meet the
assumptions of normality required by parametric tests like the t-test. This test assesses
whether the two groups come from the same population or if they are likely to have
different distributions.
Purpose of the Mann-Whitney U Test
The Mann-Whitney U Test is used to determine if two independent samples come
from the same population in terms of the variable of interest. Specifically, it asks
whether the two groups have the same distribution, which can include differences in
shape, central tendency, or spread of the data. Importantly, the test does not require the
data to follow a normal distribution.
Hypotheses in the Mann-Whitney U Test
Null hypothesis (H₀): The two populations are equal, meaning there is no
difference in the distribution of the variable between the two groups.
Alternative hypothesis (H₁): The two populations are not equal, meaning there is
a difference in the distribution of the variable between the two groups.
It is common to interpret the results of the Mann-Whitney U Test as comparing the
medians of the two populations, though the test does not directly involve medians in its
calculation. While comparing medians is a useful shorthand, the test compares the
overall distribution, which can reveal differences even if the medians are the same.
The Mann-Whitney U Test is appropriate under the following conditions:
• Non-normality of the data: This test is particularly useful when the data are not
normally distributed, making it the non-parametric alternative to the unpaired
Student’s t-test (which assumes normality in the populations).
• Continuous data: The test is designed for continuous variables, meaning the data
can take any value within a range (e.g., age, weight, or blood pressure). The data in
each group are ranked, and the ranks are compared across the two groups.
• Independent samples: The two groups being compared must be independent of one
another. If the data points are paired (e.g., measurements before and after an
intervention on the same subjects), a different test, such as the Wilcoxon Signed-
Rank Test, should be used.
• Similar distributions: While the data are not assumed to be normally distributed, the
distributions of the two groups should be similar in shape. This means that the
spread and skew of the distributions should not differ drastically.
• Sample size: There should be enough data points in each group (usually at least
five), as small sample sizes can affect the power of the test.
Calculate Mann-Whitney U-Test
• To calculate the Mann-Whitney U test for two independent samples, the rankings of
the individual values must first be determined (An example with tied ranks follows
below).
The rankings for the two groups are then summed. In the example above, the rank sum
𝑇1 for the women is 37, and the rank sum 𝑇2 for the men is 29. The average rank for
women ̅̅̅𝑅1 is 6.17, and the average rank for men ̅̅̅
𝑅2 is 5.80. The difference between ̅̅̅
𝑅1
̅̅̅
and 𝑅2 helps determine whether there are significant differences in reaction times
between the two groups. The next step involves calculating the U-values based on the
rank sums 𝑇1 and𝑇2 .
In the context of the Mann-Whitney U test, suppose you have two groups, with
𝑛1 and 𝑛2 representing the number of elements in the first and second group,
respectively. If the two groups come from the same population (i.e., they do not differ in
their distributions), the expected value of the U statistic is computed under the null
hypothesis of no difference between the groups.
To calculate the test statistic, the U value is determined for each group. The Mann-
Whitney U test uses the smaller of the two U values 𝑈1 and 𝑈2 as the test statistic. This
smaller U value reflects the degree of overlap between the two groups' distributions.
Once the U value is computed, the next step is to estimate the mean and dispersion of
the distribution of U under the null hypothesis. The z-score, which quantifies the
deviation of the observed U from its expected value under the null hypothesis, is then
calculated.
Mann-Whitney U Test with Tied Ranks
When conducting the Mann-Whitney U test, ties (i.e., when multiple observations have
the same value) can occur in the data. In such cases, tied ranks need to be adjusted,
which affects both the calculation of the rank sums and the standard deviation of the U
statistic. Below, we will walk through an example to illustrate how to handle tied ranks.
Example:
Let's say we have a set of reaction times, and we observe the following:
• Reaction time 34 occurs twice, so these two observations share the ranks 2 and
3.
• Reaction time 39 occurs three times, so these three observations share the ranks
6, 7, and 8.
How to Adjust for Tied Ranks:
1. Assigning Average Ranks:
When tied values occur, each tied value is assigned the average rank of the
positions they would occupy if there were no ties. For example:
o For the two occurrences of reaction time 34, the ranks 2 and 3 are
averaged:
Average rank for 34=2+3/2=2.5
o For the three occurrences of reaction time 39, the ranks 6, 7, and 8 are
averaged:
Average rank for 39=6+7+8/ 3=7
2. Calculating Rank Sums:
Once the average ranks are assigned, the rank sums for each group (or sample)
are calculated by adding the ranks corresponding to the observations in that
group.
3. Standard Deviation Adjustment:
The standard deviation of the U statistic is adjusted for ties by incorporating a
correction factor that accounts for the presence of ties. This ensures the test's
accuracy when dealing with tied values.
To account for tied ranks (connected ranks), the average of the ranks for each
group of tied values is calculated. In the first case, where reaction time 34 occurs twice,
the ranks 2 and 3 are averaged, resulting in a "new" rank of 2.5. In the second case,
where reaction time 39 occurs three times, the ranks 6, 7, and 8 are averaged, resulting
in a "new" rank of 7. Once these adjusted ranks are assigned, the rank sums T for each
group can be calculated.
Since the rank ties are clearly shown in the table above, a correction term is calculated,
which will later be used in the calculation of the U-value when rank ties are present.
Now that all the necessary values are available, we can proceed to calculate the z-
value, taking the tied ranks into account.
Wilcoxon signed rank test
The Wilcoxon Signed Rank Test is a non-parametric statistical method used to
compare the means of two related samples or paired observations. It is particularly
valuable when the assumptions required for parametric tests, such as the normality of
differences between pairs, are not met. Unlike the paired t-test, which assumes that the
data follows a normal distribution, the Wilcoxon Signed Rank Test does not require such
assumptions, making it suitable for a broader range of data types, including ordinal
data.
Mechanism of the Wilcoxon Signed Rank Test
• Comparison Metric: While the paired t-test compares means, the Wilcoxon Signed
Rank Test compares the ranks of the differences between paired observations. It first
calculates the absolute differences between pairs, ranks these absolute differences,
and then assigns a positive or negative sign to each rank based on the direction of
the difference (whether the second value is greater or smaller than the first).
• Statistical Significance: The test assesses whether the observed pattern of signed
ranks is due to random chance. The null hypothesis generally posits that the median
difference between pairs is zero, i.e., there is no significant difference between the
paired observations. The alternative hypothesis suggests that the median difference
is not zero.
Steps to Conduct and Interpret the Wilcoxon Signed Rank Test
1. Prepare the Data: Begin by pairing the observations and calculating the differences
between each pair.
2. Rank the Differences: Rank the absolute values of the differences, ignoring the
signs at this stage.
3. Assign Signs to the Ranks: Reintroduce the signs (positive or negative) to the
ranks based on whether the difference was positive or negative.
4. Calculate the Test Statistic: Sum the ranks for the positive differences and
separately for the negative differences. The test statistic is typically the smaller of
these two sums.
5. Interpret the Results: Compare the test statistic to the critical value from the
Wilcoxon distribution table or use a z-score approximation if the sample size is large
(usually 10 or more paired observations). If the test statistic exceeds the critical
value, the null hypothesis is rejected, indicating a significant difference between the
paired observations.
Key Features and Advantages
• Non-parametric Nature: The Wilcoxon Signed Rank Test is non-parametric, meaning
it does not assume a specific distribution of the data (e.g., normality). This makes it
particularly useful for data that are ordinal or skewed, or when outliers are present,
which might violate the assumptions of parametric tests like the paired t-test.
• Focus on Medians: Unlike the paired t-test, which focuses on comparing means, the
Wilcoxon Signed Rank Test evaluates whether the median difference between pairs
is zero. This focus on medians helps to make the test more robust in the presence of
skewed data or outliers.
• Applicability: It is especially useful for small sample sizes or when the data is not
normally distributed. In fact, for samples larger than 10 pairs, the distribution of the
test statistic approximates a normal distribution, allowing for more convenient
analysis using z-scores.
• Comparison with Parametric Tests: The Wilcoxon Signed Rank Test is conceptually
similar to both the paired sample t-test (for testing differences in means) and the
Mann-Whitney U-test (for comparing two independent samples). However, whereas
the t-test compares means and the Mann-Whitney U-test compares distributions, the
Wilcoxon Signed Rank Test is concerned with the distribution of differences within
paired data, testing whether these differences are symmetrically distributed around
zero.
Statistical Considerations
• Sample Size: For small sample sizes (fewer than 10 pairs), exact critical values from
the Wilcoxon distribution table are used. For larger sample sizes (typically 10 or
more), the distribution of the test statistic can be approximated by a normal
distribution, allowing the test statistic to be normalized into a z-score for easier
interpretation.
• Outliers and Skewed Distributions: The Wilcoxon Signed Rank Test is less sensitive
to outliers and skewed data than parametric tests because it relies on ranks rather
than raw values. This makes it a more robust tool in situations where data does not
meet the assumptions of normality.
Calculate Wilcoxon test
To calculate the Wilcoxon test for two dependent samples, the difference
between the dependent values is first calculated. After the differences are calculated,
the absolute values of the differences are used to form the rankings. It is important to
note the original sign of the differences (An example with tied ranks comes below).
Stress Stress After
Participant D=X−Y /D/ Rank
Before (X) (Y)
1 34 45 -11 11 6(-)
2 36 33 3 3 2
3 41 35 6 6 5
4 39 43 -4 4 3(-)
5 44 42 2 2 1
6 37 42 -5 5 4(-)
• In the last step, the sums of the ranks are formed, which are derived from a positive
and a negative difference. The test statistics W is then calculated from the smaller
value of 𝑇 + and 𝑇 − .
𝑊 = 𝑚𝑖𝑛. (𝑇 + , 𝑇 − )
• In this example, the test statistics W results in 8
𝑊 = 𝑚𝑖𝑛. (8, 13)
• If there is no difference in the rank sum, the expected value is
𝑛(𝑛 + 1)
𝜇𝑊 =
4
• In this example, the expected value is 10.5. The calculated test statistic must now be
tested for significance.
If the sample size is sufficiently large (greater than 25 cases), the distribution of
the test statistic can be approximated by a normal distribution. In this case, the z-value
can be calculated using the appropriate formula. If the sample size is smaller than 25,
the critical value follows a t-distribution, and you should refer to a table of critical t-
values to determine significance. Once the z-value is calculated using the Wilcoxon
signed-rank test, its significance can be assessed by comparing it to the critical value of
the standard normal distribution (for large samples) or the critical t-value (for small
samples).
Wilcoxon Signed-Rank Test with Tied Ranks
• When there are tied ranks—i.e., multiple individuals share the same rank due to
identical differences—the calculation of rank sums and the standard deviation of the
W statistic must be adjusted. Let’s go through the process using an example.
• In this example, there are three individuals who have a difference of 2. These
individuals will share the ranks 2, 3, and 4.
• There are two individuals who have a difference of 4. These individuals will share the
ranks 6 and 7.
To account for the connected ranks, the mean values of the joined ranks are calculated
in each case. In the first instance, this results in a "new" rank of 3, and in the second
instance, a "new" rank of 6.5. Now, we can proceed by calculating the rank sums for the
positive and negative ranks.
Since the rank ties are clearly visible in the upper table, a term is calculated here that is
needed for the later calculation of the W-value in the presence of rank ties.
Now all values are available to calculate the z-value considering connected ranks.
Effect size in the Wilcoxon signed-rank test
• The effect size measures the magnitude of the observed effect relative to the
random variability in the data. There are several ways to calculate the effect size in
the Wilcoxon test. One common approach is to use r, which is defined as:
Where;
z is the standardized test statistic value from the Wilcoxon test, and
n is the total number of observations (i.e., the sum of the sizes of both groups).
• The value of r can range from -1 to 1. Values near 0 suggest that there is no
meaningful effect, while values closer to -1 or 1 indicate a stronger effect. The sign
of r indicates the direction of the effect.
• The following table provides guidelines for interpreting the effect size r based on
Cohen's (1988) recommendations:
|r| < 0.1 no effect / very small effect
|r| = 0.1 small effect
|r| = 0.3 medium effect
|r| = 0.5 large effect