Mathwords logoMathwords

Spearman Rank Correlation Coefficient — Definition, Formula & Examples

The Spearman rank correlation coefficient is a number between −1 and +1 that measures how well the relationship between two variables can be described by a monotonic function, using the ranks of the data rather than the actual values.

Denoted rsr_s (or ρs\rho_s), the Spearman rank correlation coefficient is a nonparametric measure of rank correlation computed by applying the Pearson correlation formula to the ranked values of two variables. When there are no tied ranks, it simplifies to rs=16di2n(n21)r_s = 1 - \dfrac{6\sum d_i^2}{n(n^2 - 1)}, where did_i is the difference between the two ranks for each observation and nn is the number of observations.

Key Formula

rs=16i=1ndi2n(n21)r_s = 1 - \frac{6\sum_{i=1}^{n} d_i^2}{n(n^2 - 1)}
Where:
  • rsr_s = Spearman rank correlation coefficient
  • did_i = Difference between the rank of $x_i$ and the rank of $y_i$ for the $i$-th observation
  • nn = Number of paired observations

How It Works

To compute rsr_s, first rank each variable's values separately from smallest to largest. Then find the difference did_i between the two ranks for each pair. Square those differences, sum them, and substitute into the formula. A value near +1 indicates a strong increasing monotonic relationship, a value near −1 indicates a strong decreasing monotonic relationship, and a value near 0 suggests no monotonic association. Unlike Pearson's rr, Spearman's coefficient does not assume linearity or normally distributed data, making it robust to outliers and suitable for ordinal data.

Worked Example

Problem: Five students are ranked by their math score and their science score. Math ranks: 1, 2, 3, 4, 5. Science ranks: 2, 1, 3, 5, 4. Find the Spearman rank correlation coefficient.
Step 1: Compute each rank difference did_i (Math rank minus Science rank).
d1=12=1,  d2=21=1,  d3=33=0,  d4=45=1,  d5=54=1d_1 = 1-2 = -1,\; d_2 = 2-1 = 1,\; d_3 = 3-3 = 0,\; d_4 = 4-5 = -1,\; d_5 = 5-4 = 1
Step 2: Square each difference and sum them.
di2=1+1+0+1+1=4\sum d_i^2 = 1 + 1 + 0 + 1 + 1 = 4
Step 3: Substitute into the formula with n=5n = 5.
rs=16(4)5(251)=124120=10.2=0.8r_s = 1 - \frac{6(4)}{5(25 - 1)} = 1 - \frac{24}{120} = 1 - 0.2 = 0.8
Answer: rs=0.8r_s = 0.8, indicating a strong positive monotonic association between math and science ranks.

Why It Matters

Spearman's coefficient is a standard tool in introductory statistics courses whenever data are ordinal or the assumptions of Pearson's rr (linearity, normality) are not met. Researchers in psychology, ecology, and market research frequently use it to quantify monotonic associations in survey data or ranked outcomes.

Common Mistakes

Mistake: Using the simplified formula when there are tied ranks.
Correction: The shortcut formula 16di2n(n21)1 - \frac{6\sum d_i^2}{n(n^2-1)} assumes no ties. When ties exist, assign average ranks and compute rsr_s using the general Pearson correlation formula applied to the ranks.