Spearman's Rank Correlation

When we collect two numerical measurements on each individual — such as a student's study hours and their exam score — we have bivariate quantitative data. A natural question is: how strongly do these two variables move together? The most familiar answer is Pearson's correlation coefficient r, but it assumes a linear relationship and is sensitive to extreme values. Spearman's rank correlation coefficient, denoted r_s or the Greek letter ρ_s (rho), offers a powerful alternative that works even when the relationship is curved, as long as it is consistently increasing or decreasing (a property called monotonicity). The key idea behind Spearman's method is elegantly simple: instead of working with the raw data values, we replace each value with its rank — its position when the data are sorted from smallest to largest. The ranks of one variable are then compared with the ranks of the other. If a person who ranks highest on variable X also ranks highest on variable Y, and so on down the list, the two variables are in perfect agreement and r_s = 1. If the rankings are completely reversed, r_s = −1. No relationship at all gives r_s ≈ 0. Because ranks are much less affected by extreme outliers than the original measurements, Spearman's r_s is called a robust statistic. A single very large or very small value that would dramatically pull Pearson's r away from the true pattern merely occupies one extreme rank and has minimal influence on r_s. This makes Spearman's correlation particularly valuable in psychology, social science, and biology, where perfectly linear relationships are rare and unusual observations are common.

Key takeaways
  • Rank each variable independently
  • Compute the rank differences
  • Apply the shortcut formula
  • Interpret the coefficient
  • Compare with Pearson's r

Rank each variable independently

Sort the values of variable X from smallest (rank 1) to largest (rank n), assigning each observation its rank. Do the same for variable Y. If two observations have the same value (a tie), assign them the average of the ranks they would have occupied. For example, if the 3rd and 4th values are tied, both receive rank 3.5.

Compute the rank differences

For each individual i, calculate d_i = rank(X_i) − rank(Y_i), the signed difference between their rank on X and their rank on Y. These differences measure how much each person's relative standing changes from one variable to the other.

Apply the shortcut formula

When there are no ties (or very few), the convenient formula r_s = 1 − (6 Σd_i²) / (n(n²−1)) gives an exact result. The numerator 6Σd_i² grows when rankings disagree; dividing by n(n²−1) scales everything to the interval [−1, 1]. With many ties, it is more accurate to compute Pearson's r directly on the ranks rather than using this shortcut.

Interpret the coefficient

r_s = 1 means a perfect positive monotonic relationship: higher X always goes with higher Y. r_s = −1 means a perfect negative monotonic relationship. Values between 0.7 and 1 (or −0.7 and −1) are considered strong; 0.4–0.7 moderate; below 0.4 weak. Crucially, r_s measures monotonic association, not just linear association, so it can equal 1 for a curved relationship like Y = X³ over positive X values.

Compare with Pearson's r

Pearson's r measures the strength of a linear relationship using the actual numerical values and their deviations from the mean. It equals +1 or −1 only for a perfectly straight-line relationship. Spearman's r_s is always at most as large as Pearson's r would be for the ranks, and the two can differ substantially when outliers are present or when the relationship is monotonic but non-linear. For truly linear data with no outliers, both coefficients give similar values.

The Key Equation

rs=1−6∑i=1ndi 2n(n2−1)r_s = 1 - \frac{6\displaystyle\sum_{i=1}^{n} d_i^{\,2}}{n(n^2 - 1)}
  • r_s — Spearman's rank correlation coefficient (dimensionless): A value between −1 and 1 measuring the strength and direction of the monotonic relationship between two ranked variables.
  • d_i — rank difference for observation i (dimensionless): The difference between the rank of the i-th observation on variable X and the rank of the same observation on variable Y.
  • n — sample size (count): The total number of paired observations in the dataset.
  • \sum d_i^2 — sum of squared rank differences (dimensionless): All individual squared rank differences added together; larger values indicate greater disagreement between the rankings.

Worked Example

Problem. A sports scientist records the finishing position (rank) of 6 athletes in a sprint and their resting heart rate (bpm): Athlete A: sprint rank 1, HR 58; B: rank 2, HR 62; C: rank 3, HR 71; D: rank 4, HR 65; E: rank 5, HR 80; F: rank 6, HR 75. Calculate Spearman's r_s between sprint rank and HR rank to see whether faster sprinters tend to have lower resting heart rates.

rs=1−6×46(36−1)=1−24210≈0.886r_s = 1 - \frac{6 \times 4}{6(36-1)} = 1 - \frac{24}{210} \approx 0.886

Answer. r_s ≈ 0.886, indicating a strong positive monotonic association between sprint finishing position rank and resting heart rate rank.

Figure
Diagram
Pearson r vs Spearman r_s: Effect of an OutlierNo OutlierXYPearson r ≈ 0.99Spearman r_s ≈ 1.00With OutlierXYoutlierPearson r ≈ 0.41 (pulled down)Spearman r_s ≈ 0.96 (robust)The outlier (orange) severely distorts Pearson r but barely affects Spearman r_s.Pink dashed = Pearson regression line. Green dashed = underlying trend (Spearman captures).
Origins · 1 minCharles Spearman and how this was discovered
CS
Charles Spearman
1863–1945 · British

Charles Spearman was a British psychologist and statistician who introduced the rank correlation coefficient in his 1904 paper 'The Proof and Measurement of Association between Two Things'. He developed the method to study the relationship between different measures of intelligence without assuming the data followed normal distributions. Spearman is equally famous for inventing factor analysis and proposing the theory of general intelligence ('g factor'), which laid the foundation for modern IQ testing. Spearman served as a cavalry officer in the British Army before returning to academia at age 34 to pursue his passion for psychology and statistics — proving it is never too late to start a scientific career.

  • Pearson's Correlation Coefficient — Spearman's r_s is best understood in contrast to Pearson's r; both measure association but make different assumptions and respond differently to outliers and non-linearity.
  • Scatter Plots and Bivariate Data — Scatter plots allow you to visualise whether a relationship is linear or merely monotonic, helping you decide whether Pearson's r or Spearman's r_s is the more appropriate measure.
  • Outliers and Their Effects on Statistics — Understanding how outliers distort measures like Pearson's r motivates the use of robust alternatives such as Spearman's rank correlation.
  • Ranking and Ordinal Data — Spearman's method is built entirely on ranks, so understanding how to assign and interpret ranks is a prerequisite skill for computing and using r_s.