The Wilcoxon test family are nonparametric hypothesis tests for comparing two groups when the usual parametric assumptions (notably normality) are not met. They use ranks rather than raw values, so they require only ordinal or continuous data that can be ordered. Two distinct procedures are commonly called “Wilcoxon” tests
• Wilcoxon signed-rank test — for paired (dependent) samples (the nonparametric analogue of the paired Student’s t‑test).
– Wilcoxon rank‑sum test — for two independent samples; this test is often reported interchangeably with the Mann–Whitney U test (historically related to Wilcoxon’s rank methods).
Key takeaways
– The Wilcoxon tests are nonparametric rank-based methods for comparing two samples when normality cannot be assumed.
– Use the signed‑rank test for paired/dependent observations; use the rank‑sum (Mann–Whitney) test for two independent groups.
– They examine medians or distributional shifts rather than means, and are robust to outliers and non-normal distributions.
– Software (R, Python/SciPy, SPSS, Excel add-ins) performs the calculations and returns exact or asymptotic p‑values; for small samples exact tables may be used.
Background and intuition
Frank Wilcoxon introduced ranking procedures in 1945 to enable inference when data could be ordered but didn’t meet parametric assumptions.[1] The core idea is to replace raw values with ranks (absolute differences for paired data), then test whether ranks in one group tend to be larger than ranks in the other group (or whether positive ranks dominate negative ranks in paired data).
Types of Wilcoxon tests and when to use each
– Wilcoxon signed‑rank test (paired):
• Use when you have two related measurements on the same subject (before/after, matched pairs, repeated measures).
• Tests whether the distribution of differences is symmetric about zero (i.e., median difference = 0).
– Wilcoxon rank‑sum test (independent samples) / Mann–Whitney U:
• Use when two samples are independent and you want to test whether observations in one sample tend to be larger than in the other.
• If the two groups’ distributions have the same shape, the test compares medians; otherwise it detects general stochastic ordering (one distribution tends to produce larger values).
Assumptions (summary)
– Signed‑rank test:
• Pairs are independent of each other.
• Differences are measured on at least an interval scale (or ordinal but interpretable).
• The distribution of differences is symmetric around a median (we test whether that median = 0).
• Zero differences are typically excluded.
– Rank‑sum (Mann–Whitney):
• Observations are independent within and between groups.
• Data are at least ordinal.
• If making inference about medians, distributions should have the same shape; otherwise interpret as shift in distributions.
– Both tests are robust to nonnormality and to some outliers, but ties and many zero differences require small corrections or rank‑tie handling.
Wilcoxon signed‑rank test — what it tests
The signed‑rank test evaluates whether the central location (median) of the distribution of paired differences is zero. It uses the magnitudes and signs of the pairwise differences
Practical steps — Wilcoxon signed‑rank test (manual calculation)
1. For each pair, compute the difference di = (measurement2 − measurement1).
2. Remove pairs with di = 0 (ties at zero are usually excluded).
3. For remaining |di|, assign ranks from 1 (smallest |di|) to n (largest |di|). If ties in absolute differences occur, assign average ranks for tied values.
4. Restore the signs to those ranks (i.e., rank with sign of di).
5. Compute W+ = sum of ranks with positive signs, and W− = sum of ranks with negative signs.
6. The test statistic can be W = min(W+, W−) (small values indicate evidence against the null in small-sample tables) or use W+ with an asymptotic normal approximation:
• Expected value of W+ under H0: E(W+) = n(n + 1)/4
• Variance under H0: Var(W+) = n(n + 1)(2n + 1)/24 (adjust for ties if present)
• z = (W+ − E(W+)) / sqrt(Var(W+)) (use continuity correction if desired)
7. Determine p‑value from exact distribution (small n) or normal approximation (larger n), and decide on hypothesis.
Worked example (signed‑rank)
Suppose n = 6 paired differences (di): [6, −1, 4, −2, 5, −3]
Absolute values and ranks: |di| = [6,1,4,2,5,3] → ranks = [6,1,5,2,4,3]
Signed ranks: [+6, −1, +5, −2, +4, −3]
W+ = 6 + 5 + 4 = 15; W− = 1 + 2 + 3 = 6
Mean E(W+) = n(n + 1)/4 = 6·7/4 = 10.5
Var(W+) = n(n + 1)(2n + 1)/24 = 6·7·13/24 = 22.75
z ≈ (15 − 10.5)/sqrt(22.75) ≈ 0.94 → two‑tailed p ≈ 0.35 (not significant)
Wilcoxon rank‑sum test (Mann–Whitney) — what it tests
The rank‑sum test compares two independent samples to evaluate whether values in one group tend to be larger than in the other. It ranks all observations together and compares the sum of ranks between groups.
Practical steps — Wilcoxon rank‑sum / Mann–Whitney U (manual calculation)
1. Combine both samples into one ordered list and assign ranks 1 through N (average ranks for ties).
2. Compute RA = sum of ranks for group A (size nA), RB = sum of ranks for group B (size nB).
3. Compute U statistics:
• UA = nA·nB + nA(nA + 1)/2 − RA
• UB = nA·nB + nB(nB + 1)/2 − RB
• Note UA + UB = nA·nB
4. For large samples, approximate U with normal:
• E(U) = nA·nB/2
• Var(U) = nA·nB(nA + nB + 1)/12 (adjust for ties)
• z = (U − E(U)) / sqrt(Var(U))
5. Determine p‑value (exact for small n from tables, asymptotic for large n) and conclude.
Worked example (rank‑sum)
Group A: [5, 7, 8]; Group B: [2, 4, 6, 9]
Combined sorted: [2( B),4(B),5(A),6(B),7(A),8(A),9(B)]
Ranks: 1,2,3,4,5,6,7
RA = ranks of A = 3 + 5 + 6 = 14, nA = 3, nB = 4
UA = nA·nB + nA(nA + 1)/2 − RA = 3·4 + 3·4/2 − 14 = 12 + 6 − 14 = 4
Use tables or normal approx to get p-value; interpret accordingly (small UA suggests A tends to have smaller values than B).
Why choose Wilcoxon over the t‑test?
– Use when the t‑test assumptions (notably normally distributed differences for paired t, or normality and equal variances for independent t) are violated, and sample size is small or moderate.
– The Wilcoxon tests do not require normally distributed data; they are based on ranks and robust to outliers and skewed distributions.
– If the t‑test assumptions hold, the t‑test typically has greater power; otherwise the Wilcoxon tests often perform better.
Limitations
– Wilcoxon tests typically test for median differences or distributional shift, not differences in means.
– If distributions differ in shape (skewness, spread), interpretation as “difference in medians” is not strictly valid for the rank‑sum test.
– Ties and many zeros complicate exact distributions; software applies tie corrections or reports approximations.
– For very large samples, asymptotic normal approximations are used and are generally accurate.
Software implementation (practical)
– R:
• Paired signed‑rank: wilcox.test(x, y, paired = TRUE)
• Rank‑sum (independent): wilcox.test(x, y, paired = FALSE)
• R will return exact p‑values for small samples (when appropriate) and asymptotic p‑values otherwise.
– Python (SciPy):
• Signed‑rank: scipy.stats.wilcoxon(x, y) (paired)
• Rank‑sum/Mann–Whitney: scipy.stats.mannwhitneyu(x, y)
• Check SciPy docs for exact vs approximate options and handling of zero differences/ties.
– SPSS, Stata, SAS, and many GUI packages support Wilcoxon tests; check the package documentation for exact p‑value options and tie corrections.
How to report results
– State the test used (Wilcoxon signed‑rank or Wilcoxon rank‑sum / Mann–Whitney U), sample sizes, and whether an exact or asymptotic p‑value was used.
– Report the test statistic (W, U), the p‑value, and effect direction (which group had larger ranks or whether median difference > 0).
Example: “A Wilcoxon signed‑rank test on n = 20 pairs found W+ = 150, p = 0.03 (two‑tailed), indicating a statistically significant increase after treatment.”
Practical checklist before using a Wilcoxon test
1. Decide paired vs independent design.
2. Ensure data are at least ordinal and pairs/observations are independent.
3. For paired tests, check for many zero differences (decide how to handle them).
4. If sample sizes are small, request exact p‑values (if available) from software.
5. If data contain many ties, use software that applies tie corrections.
6. Complement the test with descriptive statistics (median, IQR), plots (boxplots, paired difference plots), and effect size measures (rank‑biserial correlation or r).
References and further reading
– Wilcoxon, F. (1945). “Individual Comparisons by Ranking Methods.” Biometrics Bulletin, 1(6): 80–83. [original paper]
– Investopedia. “Wilcoxon Test” (article summarizing Wilcoxon signed‑rank and rank‑sum tests). [source summary]
– R documentation: ?wilcox.test
– SciPy documentation: scipy.stats.wilcoxon and scipy.stats.mannwhitneyu
Bottom line
The Wilcoxon tests are practical, robust nonparametric alternatives to t‑tests when normality or other parametric assumptions fail. Use the signed‑rank test for paired data and the rank‑sum/Mann–Whitney test for independent samples. Modern statistical packages compute exact or asymptotic p‑values and handle ties; follow the calculation steps above to understand what the software is doing and to correctly interpret and report results.
Editor’s note: The following topics are reserved for upcoming updates and will be expanded with detailed examples and datasets.