Probability & Statistics

Kruskal–Wallis Exact Ties

Inspect tied ranks and compare a small exact allocation test with its asymptotic reference.

By Riano · Published · Updated · Report a correction

Kruskal–Wallis Exact Ties

The Kruskal–Wallis test is a non-parametric method used for comparing two or more independent samples of equal or different sample sizes. It extends the Mann-Whitney U test, which is used for comparing only two groups. When observations have identical values, they receive averaged ranks. This tie-correction scales the final test statistic H, which affects the exact permutation test probability distribution.

Worked example: Tied Data with 3 Groups of Size 2

Let us consider the "Tied" dataset where six values are sorted and partitioned into three groups: [0, 1], [1, 2], [2, 3]. First, we pool the data and compute the average ranks:

ValueRaw RanksAvg Rank
011.0
12, 32.5
24, 54.5
366.0

Using the pooled ranks, the group sum of ranks are:

  1. Group 1 [0, 1] ranks: 1.0 + 2.5 = 3.5
  2. Group 2 [1, 2] ranks: 2.5 + 4.5 = 7.0
  3. Group 3 [2, 3] ranks: 4.5 + 6.0 = 10.5

The uncorrected Kruskal-Wallis statistic Hraw is calculated as: Hraw = [12 / (6 × 7)] × [ (3.5²)/2 + (7.0²)/2 + (10.5²)/2 ] - 3 × 7 = 3.5. Since there are two ties (values 1 and 2, each with multiplicity t=2), the tie correction C is: C = 1 - [ (2³ - 2) + (2³ - 2) ] / (6³ - 6) = 1 - 12 / 210 = 0.9428571428571428. The corrected statistic H is Hraw / C = 3.712121212121212.

Interactive Experiment

You can interact with the Kruskal–Wallis Exact Ties module to see how ties and group configurations affect the test statistic and exact permutation probabilities.

  1. Select the Data control and set it to Separated to observe the behavior when there are no ties (C = 1.0).
  2. Change the Data control to Tied to observe the tie correction take effect, increasing the final H and altering the permutation reference.
  3. Change the Group probe control to view the specific Selected mean rank for each individual group without changing the global H statistic.

Limitations and Assumptions

The asymptotic Chi-Square reference p-value (which uses df = k-1 = 2) is often highly inaccurate for very small sample sizes (such as groups of size 2 used here). In this small data regime, the exact permutation test over the 90 possible group allocations provides the mathematically correct p-value.

References

More information about the Kruskal-Wallis test and its implementation details, including tie corrections, can be found in the SciPy documentation: scipy.stats.kruskal.

Experience it interactively

Adjust parameters, observe in real time, and build deep intuition with Riano’s interactive Kruskal–Wallis Exact Ties module.

Try Kruskal–Wallis Exact Ties on Riano →

More in Probability & Statistics