Spearman’s rank correlation coefficient ρ (rho) measures how well the relationship between two variables can be described by a monotonic function, one that only goes up, or only goes down, but not necessarily in a straight line. Instead of the raw values it uses their ranks: the smallest x gets rank 1, the next rank 2 and so on, and the same is done for y.
Working with ranks makes Spearman’s ρ robust. An extreme outlier is just “the largest value” and cannot dominate, a curved but steadily rising relationship such as y = x³ still gives ρ = 1, and ordinal data (survey ratings, league positions, judges’ scores) can be analysed directly. That is why ρ is the usual choice when Pearson’s assumptions of linearity and normality are doubtful.
When there are no tied values the shortcut 1 − 6Σd² ÷ (n(n² − 1)) gives ρ from the differences d between paired ranks. With ties the calculator assigns each group of tied values the average of the ranks they occupy and computes Pearson’s r on the ranks, which is the exact definition.
How to use the Spearman’s Rank Correlation Calculator
- X values
- Y values (same order as X)
Everything is calculated in your browser, so results appear instantly and nothing you type is sent to a server.
How it works
Enter the X and Y values in pairs. The calculator ranks each list (ties share the average rank), finds the rank differences d, and computes ρ as the correlation of the ranks. Significance uses the t approximation with n − 2 degrees of freedom, which is good for n of about 10 or more.
Worked example
Nine students’ scores on two tests are X = 35, 23, 47, 17, 10, 43, 9, 6, 28 and Y = 30, 33, 45, 23, 8, 49, 12, 4, 31. Ranked from smallest to largest, X becomes 7, 5, 9, 4, 3, 8, 2, 1, 6 and Y becomes 5, 7, 8, 4, 2, 9, 3, 1, 6. The rank differences d are 2, −2, 1, 0, 1, −1, −1, 0 and 0, so Σd² = 12, so ρ = 1 − 6 × 12 ÷ (9 × 80) = 0.90, a very strong positive correlation. t = 0.9 × √(7 ÷ 0.19) = 5.46 with 7 degrees of freedom, p ≈ 0.0009. Pearson’s r on the raw scores is 0.950 and Kendall’s τ-b is 0.722.
How strong is ρ?
| |r| (absolute value) | Strength (Evans, 1996) |
|---|---|
| 0.00 to 0.19 | Very weak |
| 0.20 to 0.39 | Weak |
| 0.40 to 0.59 | Moderate |
| 0.60 to 0.79 | Strong |
| 0.80 to 1.00 | Very strong |
Formula
ρ = Pearson correlation of the ranks · without ties: ρ = 1 − 6Σd² ÷ (n(n² − 1)) · t = ρ√((n − 2) ÷ (1 − ρ²)), df = n − 2
Worked example
Inputs: X values: 35, 23, 47, 17, 10, 43, 9, 6, 28; Y values (same order as X): 30, 33, 45, 23, 8, 49, 12, 4, 31.
Results: Spearman's rank correlation ρ = 0.9; Strength and direction = Very strong positive correlation; Sum of squared rank differences Σd² = 12; ρ² = 0.81; t statistic = 5.4628; Degrees of freedom = 7.
Key terms
- Rank
- The position of a value when the data are sorted from smallest to largest.
- Monotonic
- Always increasing or always decreasing, though not necessarily at a constant rate.
- Tied ranks
- Equal values given the average of the ranks they span.
Frequently asked questions
How do I calculate Spearman's rank correlation by hand?
Rank each variable from smallest to largest, subtract the paired ranks to get d, square and add them, then use ρ = 1 − 6Σd² ÷ (n(n² − 1)). For the example Σd² = 12 and n = 9, so ρ = 1 − 72 ÷ 720 = 0.9.
How are tied values ranked?
Tied values get the average of the positions they occupy. Two values sharing places 3 and 4 both get rank 3.5. With ties use the Pearson-on-ranks definition, which this calculator does automatically.
When should I use Spearman instead of Pearson?
When data are ordinal, contain outliers, are clearly non-normal, or the relationship is curved but monotonic.
What does ρ = 0 mean?
There is no monotonic trend. There may still be a non-monotonic pattern, such as a U shape.
Is the p-value exact?
It uses the t approximation, which is accurate for about 10 or more pairs. For very small samples consult exact critical-value tables.
What is the minimum sample size?
Three pairs to compute ρ, but at least 5–10 for a meaningful test.
How do I interpret ρ?
Like Pearson's r: ±0.8 or more is very strong, 0.6–0.79 strong, 0.4–0.59 moderate, 0.2–0.39 weak and below 0.2 very weak.