Spearman's Rank Correlation
What You'll Learn
You'll learn how to measure the strength and direction of a monotonic relationship between two variables by working with their ranks rather than their raw values.
Why Ranks Instead of Raw Values?
Sometimes two variables move together in a consistent direction (both increase or both decrease), but not necessarily in a straight line. Maybe one variable doubles while the other only grows by 50%—that's still a monotonic relationship, but it won't show up perfectly in Pearson's correlation.
Spearman's rank correlation solves this by converting each observation to its rank within its variable, then calculating how similarly the two sets of ranks behave. This makes it a nonparametric method: you don't need normally distributed data or a linear relationship.
How It Works
-
Rank each variable separately: The smallest value gets rank 1, next gets rank 2, and so on.
-
Calculate the difference
dbetween paired ranks. -
Apply the formula:
ρ = 1 - (6Σd²) / [n(n²-1)]
where
nis the number of pairs.
The result ranges from -1 (perfect inverse monotonic relationship) through 0 (no monotonic relationship) to +1 (perfect direct monotonic relationship).
Example Analogy
Imagine ranking students by test score and by hours studied. Even if the relationship isn't perfectly linear, students who study more tend to rank higher on the test. Spearman's ρ captures that ordinal agreement between the two rankings.
When to Use It
- When data are ordinal (ranks, ratings, positions)
- When the relationship is monotonic but not necessarily linear
- When outliers distort Pearson's correlation
- As part of nonparametric hypothesis testing
Key Takeaway: Spearman's rank correlation measures monotonic association using ranks, making it robust to outliers and appropriate for ordinal data or nonlinear monotonic relationships.