Tutorials › VEE Mathematical Statistics › Tie Correction for the Kruskal–Wallis Statistic

VEE Mathematical Statistics · Rank-Based and Distribution-Free Tests · Tutorial 860 of 880

Tie Correction for the Kruskal–Wallis Statistic

Derive the Kruskal–Wallis tie correction and apply it carefully when pooled observations share values.

Intermediate 11 min read

What You'll Learn

  • Assign midranks to tied observations in the pooled sample.
  • Identify tied-block sizes across all groups.
  • Derive the correction factor from the reduction in rank dispersion.
  • Calculate both uncorrected and tie-corrected Kruskal–Wallis statistics.
  • Recognize when ties make the ordinary correction undefined.
  • Avoid errors in midrank arithmetic and tie-block counting.

Why Ties Change the Kruskal–Wallis Calculation

The Kruskal–Wallis statistic compares the rank distributions of several independent groups. To rank the observations, first pool them across groups. If two or more observations have the same value, they receive the average of the ranks they would have occupied. This is called a midrank.

Midranks preserve the total of all ranks, but ties reduce the spread of the pooled ranks. The usual Kruskal–Wallis formula is scaled for the spread of distinct ranks \(1,2,\ldots,N\). When values repeat, using that formula without adjustment can understate the statistic relative to the reduced rank dispersion. The tie correction accounts for this change.

Definition: Suppose \(k\) independent groups contain \(n_j\) observations in group \(j\), for \(j=1,\ldots,k\), and \(N=\sum_{j=1}^k n_j\). Pool the observations and assign midranks to tied values. Let \(R_j\) be the sum of the ranks in group \(j\). If the pooled sample has tied blocks of sizes \(t_1,\ldots,t_g\), define $$ C=1-\frac{\sum_{\ell=1}^g(t_\ell^3-t_\ell)}{N^3-N}. $$ The uncorrected Kruskal–Wallis statistic is $$ H=\frac{12}{N(N+1)}\sum_{j=1}^k\frac{R_j^2}{n_j}-3(N+1), $$ and, when \(C>0\), the tie-corrected statistic is \(H_{\mathrm{corr}}=H/C\). A tied block is counted once, using its size in the pooled data, not separately within each group.

A tied block of size one contributes \(1^3-1=0\), so singleton values need not be included in the sum. If there are no ties, every block has size one, \(C=1\), and the correction leaves \(H\) unchanged. When at least two distinct pooled values occur, \(C\) is positive and less than or equal to one.

Why the Correction Has This Form

The correction factor measures how much ties reduce the total squared spread of the pooled ranks. Without ties, the ranks are \(1,\ldots,N\), whose squared deviations from their mean \((N+1)/2\) sum to \(N(N^2-1)/12\). Replacing the distinct ranks within a tied block by their common midrank removes that block’s within-block variation.

For a tied block of size \(t\), the ranks it would have occupied are consecutive. Their average is the assigned midrank. The sum of squared deviations of those consecutive ranks from their average is \(t(t^2-1)/12=(t^3-t)/12\). The block is therefore responsible for exactly this reduction in squared rank spread.

$$ \sum_{i=1}^N\left(r_i-\frac{N+1}{2}\right)^2 =\frac{N(N^2-1)}{12}-\sum_{\ell=1}^g\frac{t_\ell^3-t_\ell}{12} =C\,\frac{N(N^2-1)}{12}. $$

Here \(r_i\) denotes the pooled midrank of observation \(i\). Since \(N(N^2-1)=N^3-N\), the ratio of tied-rank spread to untied-rank spread is precisely \(C\). Under the random allocation of a fixed set of pooled ranks to groups, the variance of each group’s rank sum scales in the same proportion as the total rank spread. The uncorrected statistic uses the untied-rank scale; dividing by \(C\) adjusts it to the smaller spread caused by ties. This explains the form \(H_{\mathrm{corr}}=H/C\).

This correction changes the statistic, not the underlying midranks or group rank sums. It also does not by itself specify a reference distribution or a decision rule; those depend on the testing procedure and its conditions.

Calculating Midranks and the Correction

Worked Example: One Tied Block Across Two Groups

Method. Pool and rank all six observations, calculate the group rank sums, then apply the correction using the size of the pooled tied block. Group A has values \(1,2,2\), and Group B has values \(2,3,4\). Calculate \(H\) and \(H_{\mathrm{corr}}\).

Pooled ranks. The value 1 receives rank 1. The three observations equal to 2 occupy ranks 2, 3, and 4, so each receives midrank \((2+3+4)/3=3\). The values 3 and 4 receive ranks 5 and 6.

Group rank sums. Group A has ranks \(1,3,3\), so \(R_A=7\). Group B has ranks \(3,5,6\), so \(R_B=14\). The check \(R_A+R_B=7+14=21=6(7)/2\) confirms the ranks sum to the total of ranks 1 through 6.

Uncorrected statistic. With \(N=6\) and \(n_A=n_B=3\),

$$ H=\frac{12}{6(7)}\left(\frac{7^2}{3}+\frac{14^2}{3}\right)-3(7) =\frac{2}{7}\left(\frac{245}{3}\right)-21 =\frac{70}{3}-21 =\frac{7}{3}=2.3333. $$

Tie correction. There is one tied block of size 3, so

$$ C=1-\frac{3^3-3}{6^3-6} =1-\frac{24}{210} =\frac{31}{35}. $$

Therefore,

$$ H_{\mathrm{corr}}=\frac{7/3}{31/35} =\frac{245}{93} \approx 2.6344. $$

The arithmetic check is \(245/93\approx2.6344\), which is greater than \(7/3\), as expected because \(0<C<1\) and \(H_{\mathrm{corr}}=H/C\). The common mistake avoided here is using the tied value’s frequency within only one group; the tied block has size 3 in the pooled observations.

Worked Example: Two Tied Blocks

Method. Rank the pooled data with midranks, then include both pooled tied-block sizes in \(C\). Group A has values \(1,2,2,5\), and Group B has values \(2,3,5,5\).

Pooled ranks. The value 1 has rank 1. The three 2s occupy ranks 2–4 and each receive rank 3. The value 3 has rank 5. The three 5s occupy ranks 6–8 and each receive rank 7.

Group rank sums. Group A’s ranks are \(1,3,3,7\), giving \(R_A=14\). Group B’s ranks are \(3,5,7,7\), giving \(R_B=22\). Their total is \(36=8(9)/2\), as required.

Uncorrected statistic. Here \(N=8\) and both group sizes are 4:

$$ H=\frac{12}{8(9)}\left(\frac{14^2}{4}+\frac{22^2}{4}\right)-3(9) =\frac{1}{6}(49+121)-27 =\frac{85}{3}-27 =\frac{4}{3}=1.3333. $$

Tie correction. The two tied blocks each have size 3. Thus,

$$ C=1-\frac{(3^3-3)+(3^3-3)}{8^3-8} =1-\frac{48}{504} =\frac{19}{21}. $$

The corrected statistic is

$$ H_{\mathrm{corr}}=\frac{4/3}{19/21} =\frac{28}{19} \approx1.4737. $$

As a check, the two group rank sums total 36, and the correction is greater than one when applied to the positive uncorrected statistic. The common mistake avoided is counting all six tied observations as one block; there are two blocks, each of size 3.

A Full Ranking Example and a Midrank Trap

Worked Example: Ties in Two Parts of the Pooled Order

Method. Assign each tied block its pooled midrank before calculating any group sum. Then use the full block-size list in the correction. Group A has values \(1,2,2\), Group B has values \(2,3,4\), and Group C has values \(4,4,5\).

Ranks. The pooled value 1 has rank 1; the three 2s occupy ranks 2–4 and each receive rank 3; the value 3 has rank 5; the three 4s occupy ranks 6–8 and each receive rank 7; and the value 5 has rank 9.

Group sums and check. The group rank sums are \(R_A=1+3+3=7\), \(R_B=3+5+7=15\), and \(R_C=7+7+9=23\). Their total is \(45=9(10)/2\), matching the total rank sum.

Uncorrected statistic. Each group has size 3, and \(N=9\):

$$ H=\frac{12}{9(10)}\left(\frac{7^2}{3}+\frac{15^2}{3}+\frac{23^2}{3}\right)-3(10) =\frac{2}{15}\left(\frac{803}{3}\right)-30 =\frac{1606}{45}-\frac{1350}{45} =\frac{256}{45}\approx5.6889. $$

Correction. There are two tied blocks, each of size 3, so

$$ C=1-\frac{24+24}{9^3-9} =1-\frac{48}{720} =\frac{14}{15}. $$

Consequently,

$$ H_{\mathrm{corr}}=\frac{256/45}{14/15} =\frac{128}{21} \approx6.0952. $$

The answer is checked by \(H_{\mathrm{corr}}>H\), since \(C=14/15<1\). The common mistake avoided is assigning a tied block a rank based only on the first rank it occupies. Each observation equal to 4 receives the average \((6+7+8)/3=7\).

A related arithmetic trap is worth stating explicitly. If two tied observations occupy ranks 8 and 9, each receives \((8+9)/2=8.5\), not 7.5. The latter does not average the ranks occupied by the tied observations and would change every group sum that included one of those observations.

Practical Checks and Limitations

Before using a corrected statistic, check the ranking and the tie accounting separately. A good workflow is to record the pooled values, their multiplicities, their assigned midranks, and then the group rank sums. Only after those checks should the statistic be calculated.

1
Pool and rank.
Combine all group observations. Assign each observation in a tied block the average of the consecutive ranks that block occupies.
2
Check rank totals.
Verify that the group rank sums add to \(N(N+1)/2\). This catches many midrank and transcription errors.
3
List pooled tie sizes.
For each repeated value, record its total frequency across all groups. Calculate \(t^3-t\) for each such block.
4
Calculate both statistics.
Find the uncorrected \(H\), calculate \(C\), and divide \(H\) by \(C\) when \(C>0\).

Because \(C\leq1\), a positive \(H\) cannot become smaller after this correction. This does not mean that ties always create stronger evidence in every inferential sense: the correction only adjusts the statistic for the reduced rank spread, and the reference method still matters.

If every observation has the same value, there is one tied block of size \(N\), and \(C=1-(N^3-N)/(N^3-N)=0\). All observations then have the same midrank, so the groups have no rank separation. Dividing by \(C\) is undefined; the ordinary tie-corrected statistic cannot be calculated. Do not treat this as a numerical rounding issue.

Key takeaway: Use pooled midranks for the group sums and pooled tied-block sizes for the correction. Calculate \(H_{\mathrm{corr}}=H/C\) only when \(C>0\), and verify that the group rank sums total \(N(N+1)/2\).

Check Your Understanding

For each problem, calculate the requested statistic from the stated pooled observations. Round decimal answers to four places.

  1. Group A has values \(1,2,2\), and Group B has values \(2,3\). Find \(H\), \(C\), and \(H_{\mathrm{corr}}\). (Answer: \(H=1.3333,\ C=0.8000,\ H_{\mathrm{corr}}=1.6667\))
  2. Group A has values \(2,4,6\), and Group B has values \(1,3,5\). Find \(H\) and state whether a tie correction changes it. (Answer: \(H=0.4286,\ C=1,\ H_{\mathrm{corr}}=0.4286\))
  3. Group A has values \(1,2,2\), and Group B has values \(2,3,4,4\). Find the corrected statistic. (Answer: \(H=3.1250,\ C=51/56,\ H_{\mathrm{corr}}=175/51\approx3.4314\))
  4. Group A has values \(5,7\), Group B has values \(5,8,9\), and Group C has values \(7,9,10\). Find \(H\) and \(H_{\mathrm{corr}}\). (Answer: \(H=89/36\approx2.4722,\ C=27/28,\ H_{\mathrm{corr}}=623/243\approx2.5638\))
  5. Three groups contain a total of 8 observations, and every observation has the same value. What is \(C\), and can the usual corrected statistic be obtained? (Answer: \(C=0\); no, division by zero is undefined and the tied ranks contain no group separation.)
Clinical Biostats