Overview
Spearman's rank correlation measures how consistently two variables rise or fall together, using ranks instead of raw values. It works for ordinal data and isn't thrown off by outliers.
Rank each variable, find the difference in ranks for each pair, square and add them. Enter that sum with the number of pairs and your alpha.
Worked examples
| Inputs | Result |
|---|---|
| Sample Size (n)25Sum of Squared Rank Differences (Σd²)480Alpha (%)5 | Spearman rho: 0.82t-statistic: 6.75p-value (t approximation): <0.0001Statistically significant at alpha=5% |
Show 2 more examples
| Sample Size (n)10Sum of Squared Rank Differences (Σd²)30Alpha (%)5 | Spearman rho: 0.82t-statistic: 4.02p-value (t approximation): 0.00381Statistically significant at alpha=5% |
| Sample Size (n)40Sum of Squared Rank Differences (Σd²)9,000Alpha (%)5 | Spearman rho: 0.16t-statistic: 0.97p-value (t approximation): 0.34Not statistically significant at alpha=5% |
Spearman rho by sample size
With the calculator's starting values, the spearman rho is 0.82. The table shows how it changes with the sample size.
| Sample Size (n) | Spearman rho |
|---|---|
| 15 | 0.14 |
| 20 | 0.64 |
| 25starting value | 0.82 |
| 30 | 0.89 |
| 35 | 0.93 |
Other inputs: Sum of Squared Rank Differences: 480 Σd² · Alpha: 5%. Change them in the calculator above for your own numbers.
How it works
ρ is 1 minus 6Σd² divided by n(n² − 1). It's 1 when the rankings match exactly and −1 when they're reversed. The formula assumes no tied ranks, so with many ties, compute Pearson's r on the ranks instead. The p-value uses the usual t approximation, which is less accurate for very small n.
The formula
| d | Difference between a pair's two ranks |
| n | Number of pairs |
Practical tips
- With 25 pairs and Σd² = 480, ρ is about 0.82, a strong positive relationship.
- For 10 pairs with Σd² = 30, ρ = 1 − 180 ÷ 990, about 0.82.
- Spearman picks up any steady rise or fall, even a curved one, as long as it keeps going the same way.
Frequently asked questions
When should I use Spearman instead of Pearson?
For ranked data, clearly non-normal data, or outliers, or when the relationship isn't a straight line.
How do I handle tied ranks?
Give tied values the average of the ranks they cover.
What counts as a strong correlation?
Roughly above 0.7, but significance depends on the sample size too.