Tutorials › Introduction to Statistics › Ties and Average Ranks

Nonparametric Alternatives · Tutorial 949 of 996

Ties and Average Ranks

You will learn to assign midranks to ties and calculate how they change rank sums and other rank-based statistics.

Intermediate 10 min read

What You'll Learn

  • Identify the rank positions occupied by a tied group.
  • Calculate the average rank, or midrank, for tied observations.
  • Verify that midranks preserve the total of all rank positions.
  • Calculate group rank sums when pooled observations include ties.
  • Rank repeated measurements within subjects when the analysis calls for within-subject comparisons.
  • Explain how tied ranks affect a statistic without changing the observations themselves.

Why Ties Need a Consistent Rule

Ranking replaces measured values with their positions in an ordered list. If every value differs, each observation has an unambiguous rank. But real data often contain repeated values: measurements may have been rounded, or several individuals may genuinely share the same recorded value. A ranking rule must give equal observations equal treatment rather than arbitrarily deciding that one tied observation came first.

The standard solution is to assign each observation in a tied group the average of the rank positions that group occupies. These are called average ranks, or midranks. A midrank need not be a whole number. It is a summary of the tied observations' positions, not a new measurement in the original units.

Definition: Sort the \(N\) observations from smallest to largest and number their positions \(1,\ldots,N\). If a group of \(m\) equal observations occupies positions \(a,a+1,\ldots,b\), assign each observation in the group the midrank \((a+b)/2\). Here \(b-a+1=m\).

The ranking set must be defined before assigning ranks. For a pooled comparison, rank all observations in the specified groups together. For a within-subject comparison, rank the measurements separately within each subject if the analysis is based on each subject's relative ordering. These choices answer different questions; midranks resolve ties within the chosen ranking set, but do not determine which set is appropriate.

Calculating Midranks

For a tied group, find its first and last rank positions and average them. For example, if three equal observations occupy positions 4, 5, and 6, each receives rank \((4+6)/2=5\). The three ranks are therefore 5, 5, and 5, not 4, 5, and 6. Their assigned ranks still add to 15, the sum of the occupied positions.

Worked Example: Ranking a Short List With a Tie

Suppose five hypothetical recorded values are \(2, 4, 4, 7, 9\). Rank the observations from smallest to largest, assigning average ranks to equal values.

The value 2 occupies position 1, so its rank is 1. The two observations equal to 4 occupy positions 2 and 3. Each receives the midrank \[ \frac{2+3}{2}=2.5. \] The values 7 and 9 occupy positions 4 and 5, respectively. In the original observation order, the assigned ranks are \(1, 2.5, 2.5, 4, 5\).

The ranks add to \(1+2.5+2.5+4+5=15\). The sum of the five integer positions is also \(1+2+3+4+5=15\), so the tie has not changed the total rank sum. Notice that the two observations equal to 4 receive the same rank; giving one rank 2 and the other rank 3 would make their treatment depend on an arbitrary ordering.

Why the Total Rank Sum Is Preserved

Midranks preserve the total of all ranks because each tied group receives, in total, exactly the sum of the positions it occupies. This fact is useful as an arithmetic check and explains why average ranks are a natural way to handle ties.

Result: When all \(N\) observations are ranked from 1 through \(N\), assigning each tied group its midrank leaves the sum of all assigned ranks equal to \(N(N+1)/2\).

To justify the result, consider one tied group occupying positions \(a\) through \(b\), with \(m=b-a+1\) observations. Its midrank is \((a+b)/2\), so the sum of the \(m\) assigned ranks is \[ m\frac{a+b}{2}. \] The integer positions from \(a\) through \(b\) form an arithmetic sequence with \(m\) terms and average \((a+b)/2\). Their sum is also \(m(a+b)/2\). Thus the tied group contributes the same total as its occupied positions would have contributed without averaging. The tie groups and untied observations together partition all positions \(1,\ldots,N\), whose sum is \(N(N+1)/2\). Therefore the overall rank sum is unchanged.

This result concerns the sum of the ranks, not the individual ranks or every statistic calculated from them. Replacing distinct ranks with equal midranks can change a group’s rank sum, a contrast between groups, or another statistic that depends on which observations belong to which group.

Ties in Pooled Groups and Rank Sums

A rank sum is the sum of the ranks belonging to a specified group. In a pooled ranking, tied observations receive the same midrank regardless of group membership. The resulting rank sums can be fractional, and their total across all groups must equal the overall rank total.

Worked Example: Pooled Ranks and a Group Rank Sum

Two hypothetical groups have the following recorded values: Group A has \(3, 5, 5, 8\), and Group B has \(2, 5, 7, 9\). Rank the eight values together, then calculate each group's rank sum and a centered rank-sum statistic for Group A.

In increasing order, the pooled values are \(2\) (B), \(3\) (A), \(5\) (A, A, B), \(7\) (B), \(8\) (A), and \(9\) (B). The three values equal to 5 occupy positions 3, 4, and 5, so each receives rank \((3+5)/2=4\). The ranked observations are:

  • Group A: ranks \(2, 4, 4, 7\), giving rank sum \(R_A=2+4+4+7=17\).
  • Group B: ranks \(1, 4, 6, 8\), giving rank sum \(R_B=1+4+6+8=19\).

The check is \(R_A+R_B=17+19=36\), equal to \(8(8+1)/2=36\). For illustration, define the centered rank-sum statistic for Group A as its rank sum minus the rank sum it would have if its four observations had the overall average rank:

$$ T_A = R_A - n_A\frac{N+1}{2} =17-4\frac{8+1}{2} =17-18 =-1. $$

This calculation shows how the tie contributes: the two A observations and one B observation equal to 5 each receive rank 4. If those three observations were arbitrarily assigned ranks 3, 4, and 5, the two A observations' contribution could be 7, 8, or 9, depending on the arbitrary ordering. Midranks give their contribution \(4+4=8\), avoiding that arbitrary choice. The rank sum and centered statistic are descriptive calculations here; this example does not determine a p-value or make an inferential conclusion.

Repeated Measurements: Choose the Ranking Set

Repeated measurements make the ranking set especially important. If the aim is to compare measurements within each subject, rank that subject's measurements separately. A tie between two measurements for one subject receives a midrank within that subject's measurements. The ranks then describe relative position within a subject, not the subject's position among every measurement in the dataset.

Worked Example: Within-Subject Ranks With Repeated Values

In a hypothetical exercise, three subjects each have measurements at three visits. The measurements, in visit order, are: Subject 1, \(10, 12, 12\); Subject 2, \(8, 8, 11\); Subject 3, \(9, 10, 13\). Rank the three measurements separately for each subject, then find the sum of ranks at the second visit.

For Subject 1, the ordered values are \(10,12,12\). The 10 gets rank 1; the two 12s occupy positions 2 and 3 and each receive rank \((2+3)/2=2.5\). The ranks in visit order are \(1,2.5,2.5\).

For Subject 2, the ordered values are \(8,8,11\). The two 8s each receive rank \((1+2)/2=1.5\), and 11 gets rank 3. The ranks in visit order are \(1.5,1.5,3\).

Subject 3 has distinct ordered values \(9,10,13\), with ranks \(1,2,3\). The rank at the second visit is therefore 2.5 for Subject 1, 1.5 for Subject 2, and 2 for Subject 3. Their rank sum is \(2.5+1.5+2=6\). Each subject's ranks sum to \(1+2+3=6\), including the subjects with ties, as the midrank rule requires.

These within-subject ranks answer a different question from ranking all nine measurements together. For instance, Subject 1's rank 2.5 says that the second and third visit values are tied for the highest position among that subject's three measurements. It does not say how those values compare with measurements from the other subjects.

What Ties Change in a Rank-Based Statistic

A statistic calculated from ranks depends on how ranks are assigned to observations. Midranks preserve the total rank sum, but they can alter a particular group’s rank sum or any statistic that weights ranks by group membership. The pooled example showed this directly: the tied observations contributed \(4+4\) to Group A and 4 to Group B. Which group contains each tied observation matters to the group-specific sums.

The same principle applies to other rank-based summaries. If a statistic adds selected ranks, multiplies ranks by fixed weights, or forms differences between rank sums, use the midranks assigned under the stated ranking rule. Do not replace them with arbitrary consecutive ranks, and do not round them before calculating. For example, rounding a midrank of 2.5 to 3 changes the sum and can change a downstream statistic.

A rank sum by itself is not enough to establish statistical significance. Inference requires a particular procedure, its assumptions, and a suitable reference distribution; methods for those steps are addressed separately. The purpose here is to get the rank assignments and arithmetic right so that any later calculation starts from a consistent set of ranks.

1
Define the ranking set.
Decide which observations are ranked together, such as all observations in a pooled comparison or the measurements within one subject.
2
Order and locate ties.
Sort the recorded values and identify the consecutive rank positions occupied by each group of equal values.
3
Assign midranks and calculate.
Give every observation in a tie the average of its occupied positions, then calculate the requested rank sums or statistic without rounding intermediate ranks.
4
Check the arithmetic.
For a complete ranking of \(N\) observations, verify that all assigned ranks sum to \(N(N+1)/2\).

Common Mistake: Breaking Ties Arbitrarily

A tempting approach is to sort tied observations by their row order and give them consecutive ranks. That assigns different ranks to observations with the same recorded value. In a group comparison, it can also make the result depend on which tied observation happened to be listed first.

The correction is to average all the rank positions occupied by the tie and assign that average to each tied observation. If the tie occupies positions 6 and 7, both observations receive rank 6.5. Then retain the decimal ranks through the rank-sum calculation and check the overall total. Remember also that tied values must be identified using the precision of the data as recorded: values recorded as equal receive a tie under that ranking, even if the underlying unrounded quantities might have differed.

Key takeaway: Rank equal recorded values equally by assigning each the midrank of the positions it occupies. This preserves the overall rank total, while group-specific rank sums and rank-based statistics can still depend on how tied observations are distributed across groups.

Check Your Understanding

Work through these questions using average ranks for ties.

  1. Four ordered observations have values \(1, 3, 3, 6\). What rank does each observation receive, and what is the total rank sum?
  2. A tied group occupies positions 5, 6, and 7. Calculate its midrank and the sum of the ranks assigned to the three observations.
  3. Why can two group rank sums change when ties are present even though the overall sum of ranks is unchanged?
  4. Three measurements from one subject are \(4, 4, 9\). If ranking is within subject, what are the ranks in measurement order?
  5. Explain why ranking measurements separately within each subject is not the same operation as ranking every measurement in a pooled dataset.