Tutorials › Introduction to Statistics › Converting Observations to Ranks

Nonparametric Alternatives · Tutorial 948 of 996

Converting Observations to Ranks

Learn to convert distinct measurements into ranks and understand how that conversion changes the information available for statistical analysis.

Intermediate 10 min read

What You'll Learn

  • Assign ranks to distinct observations using their ordered positions.
  • Distinguish ranking one sample from ranking observations pooled across groups.
  • Explain why ranks preserve order but discard measurement distances and units.
  • Identify when strictly increasing transformations leave ranks unchanged.
  • Recognize that ranks alone do not remove the assumptions of an inferential procedure.

Why Convert Measurements to Ranks?

A measurement such as 18 minutes tells us more than that one observation came before another: it also gives a unit and a distance from other measurements. A rank keeps the ordering information but replaces the measurements with their positions in an ordered list. This can be useful when an analysis is based on relative order rather than on the original numerical distances.

For example, researchers may want to compare which observations tend to be larger without having a strong reason to treat every numerical gap as informative. Ranking changes the data used in the comparison: a value that is far above the rest receives a higher position, but its exceptional distance is no longer represented. The conversion is simple, yet understanding what it retains and loses is essential before interpreting a rank-based procedure.

Definition: For \(n\) distinct observations, the rank of an observation is its position when all \(n\) observations are sorted from smallest to largest. The smallest observation receives rank 1, the next smallest rank 2, and the largest rank \(n\). Thus, when there are no ties, the ranks are exactly the integers \(1,2,\ldots,n\), each used once.

Assigning Ranks Within One Set

To rank a set of distinct values, first sort them in ascending order. Then assign 1 to the smallest value, 2 to the next smallest, and continue until the largest has rank \(n\). Finally, attach each rank to the observation that produced it. Ranking does not change which observation is which; it replaces each recorded measurement with an ordered position.

A compact definition makes the rule precise. If \(x_i\) is one observation among \(n\) distinct values, its rank \(r_i\) is one plus the number of observations smaller than it:

$$ r_i=1+\#\{j:x_j<x_i\}. $$

Here, \(\#\) means “the number of elements in the set.” The formula gives rank 1 when no observation is smaller and rank \(n\) when all other \(n-1\) observations are smaller.

Worked Example: Ranking Five Distinct Measurements

Suppose a hypothetical set of five devices records operating times, in minutes, of 16, 9, 22, 13, and 5. Convert the observations to ranks, using rank 1 for the smallest time.

Sort the times: \(5<9<13<16<22\). Their ordered positions are 1 through 5, respectively. Returning to the original order gives:

Operating time (minutes)Rank
164
92
225
133
51

For instance, three values (5, 9, and 13) are smaller than 16, so \(r=1+3=4\) for the 16-minute observation. The ranking says that this device had the fourth-smallest operating time. It does not say how many minutes separated it from the third- or fifth-ranked device.

Choosing the Set to Rank

A rank is meaningful only in relation to the set of observations being ordered. If the goal is to compare values from two groups, the usual comparison ranks the observations together, in one pooled set. Ranking each group separately would assign each group's smallest observation rank 1, even if the smallest value in one group were much larger than every value in the other.

For example, if group A has values 20 and 30 and group B has values 2 and 10, ranking within each group gives ranks 1 and 2 in both groups. Those separate rankings hide the fact that both A values exceed both B values. Ranking the four observations together instead gives group B ranks 1 and 2 and group A ranks 3 and 4. The comparison set must therefore match the question being asked.

Pooled ranks still do not show the sizes of the gaps between groups. They show only the order of all observations in the pooled set. The following example illustrates how much the distances can matter to the original measurements.

Worked Example: Ranking Two Groups Together

In a hypothetical exercise, three observations in group A are 2, 8, and 9 units, while three observations in group B are 3, 4, and 100 units. The six measurements are distinct. Rank them together from smallest to largest and calculate each group's rank sum.

The pooled ordering is \(2_A<3_B<4_B<8_A<9_A<100_B\). Thus, the ranks are 1 through 6 in that order.

GroupMeasurementPooled rank
A21
B32
B43
A84
A95
B1006

The rank sum for group A is \(1+4+5=10\), and the rank sum for group B is \(2+3+6=11\). For comparison, the original group means are

$$ \bar{x}_A=\frac{2+8+9}{3}=\frac{19}{3}\approx6.333,\qquad \bar{x}_B=\frac{3+4+100}{3}=\frac{107}{3}\approx35.67. $$

The rank sums are close, even though group B's mean is much higher because of its value of 100. This contrast is not a test result and does not establish that either group tends to be larger. It demonstrates that ranking makes the distance from 9 to 100 count no more than the distance from 8 to 9: each neighboring position changes the rank by one.

What Ranks Preserve and What They Discard

Replacing measurements with ranks preserves their order. If observation \(x_i\) is smaller than \(x_j\), then \(r_i<r_j\). When observations are distinct, their ranks also preserve all statements about which observation is first, second, or last in the chosen set.

Ranking does not preserve measurement units, the size of a difference, or ratios between values. A difference of one rank position is not necessarily a fixed difference in the original units. In the previous example, the difference between 2 and 3 is 1 unit, while the difference between 9 and 100 is 91 units; both pairs are one rank apart. Nor can ranks tell us whether measurements doubled or increased by a particular amount.

The loss of units can be useful when the analysis is meant to depend on order and not on the exact scale of measurement. It can also be costly: if the sizes of differences are scientifically important, converting to ranks discards relevant information. Ranking is not a harmless relabeling of the same numerical data; it deliberately changes what a subsequent analysis can use.

Key takeaway: Ranks represent relative positions within a specified set. They retain order, but not the original units, distances, or magnitude of gaps. Whether that trade-off is appropriate depends on the question and the method being used.

Why Increasing Transformations Keep the Ranks

An important property of ranks is that a strictly increasing transformation leaves them unchanged. A function \(g\) is strictly increasing when \(x_i<x_j\) always implies \(g(x_i)<g(x_j)\). Such a transformation may change the numerical scale, but it cannot change the ordering.

This result follows directly from the rank definition. For every pair of distinct observations, strict increase gives \(x_j<x_i\) if and only if \(g(x_j)<g(x_i)\). Therefore, exactly the same observations are smaller than \(x_i\) and than \(g(x_i)\). The number of smaller observations is unchanged, so the rank is unchanged:

$$ r_i(x)=1+\#\{j:x_j<x_i\} =1+\#\{j:g(x_j)<g(x_i)\} =r_i(g(x)). $$

This justification applies to the full ranking of a distinct set. If a transformation reverses order instead of preserving it, the rank order reverses as well. In particular, under a strictly decreasing transformation, the rank of each transformed value is \(n+1-r_i\). That is because the observation that was in position \(r_i\) becomes the observation with \(n-r_i\) values below it, giving transformed rank \(1+(n-r_i)=n+1-r_i\).

Worked Example: A Nonlinear Transformation

A hypothetical instrument records four distinct positive readings: 1, 2, 4, and 7 units. Consider transforming each reading by squaring it. Find the ranks before and after transformation.

The original readings are already ordered, so their ranks are 1, 2, 3, and 4. Squaring gives \(1^2=1\), \(2^2=4\), \(4^2=16\), and \(7^2=49\). These transformed values remain in ascending order, so their ranks are also 1, 2, 3, and 4.

The transformation changes the numerical gaps: the original gaps are 1, 2, and 3 units, whereas the transformed gaps are 3, 12, and 33 squared units. Yet the ranks do not change. This example shows why a rank-based analysis may be unaffected by a strictly increasing change of scale even when analyses based on numerical distances would change.

Ranks and Statistical Inference

Converting observations to ranks is a data transformation, not a complete inferential method. A rank-based test uses ranks according to a particular procedure, and its interpretation depends on that procedure's assumptions and on how the data were collected. Ranking by itself does not make observations independent, repair a biased sample, or guarantee that a test's assumptions hold.

This distinction matters when non-normality motivates considering a nonparametric alternative. A rank-based method may avoid relying on the original measurements in the same way as a method built directly from those values, but it still requires appropriate design and assumptions. The earlier material on choosing nonparametric tests under non-normality addresses selecting a suitable method; the mechanics of ranking explain how one part of that analysis represents the data.

Also check which observations should be ordered together. A rank of 4 in a set of five is not the same relative position as rank 4 in a set of fifty. Ranks are neither measurements on an absolute scale nor directly comparable without their reference set. For a pooled group comparison, the pooled set supplies the common reference; ranks assigned separately within groups answer a different question.

Common Mistakes

  • Reading rank gaps as measurement gaps. A two-rank difference does not mean a fixed difference in original units. Ranks show positions, not distances.
  • Ranking comparison groups separately. Separate ranks can conceal which group's observations are larger overall. Pool the observations when the intended comparison is their relative ordering in one combined set.
  • Assuming ranking keeps all useful information. A very large value receives only the next available rank; its distance from the other values is discarded.
  • Assuming rank conversion alone validates an inference. The design and assumptions of the chosen test still matter. A rank transformation does not by itself make a study unbiased or observations independent.

Check Your Understanding

Use distinct observations in each question.

  1. Rank the values 12, 4, 19, and 7 from smallest to largest. What rank does 12 receive?
  2. Two groups have values A: 14, 20 and B: 3, 10. Explain why ranking all four values together gives a different comparison from ranking each group separately.
  3. What information about the original measurements is lost when they are replaced by ranks?
  4. Why do the ranks remain unchanged when all positive observations are squared?
  5. A rank-based analysis is chosen because the original measurements are not normally distributed. Does assigning ranks alone establish that the analysis is appropriate? Explain.