What this calculator does
Spearman correlation replaces the data with its ranks and correlates those instead. It measures whether the relationship is consistently increasing or decreasing, not whether it is a straight line.
That distinction matters. A relationship that rises steeply then levels off is not linear at all, so Pearson correlation would report less than 1, but Spearman returns exactly 1 because the ordering is perfectly preserved. Working on ranks also makes the measure indifferent to outliers, since an extreme value simply becomes the highest rank.
The formula
Both variables are converted to ranks, with tied values receiving the average of the ranks they span. The correlation is then 1 minus 6 times the sum of squared rank differences divided by n(n²−1). Where ties are present the calculator uses the average-rank method, which keeps the result consistent with computing Pearson correlation on the ranks directly.
| Term | Meaning |
|---|---|
| Monotonic | Consistently increasing or decreasing, without needing to be a straight line. |
| Rank | Position when sorted, with ties averaged. |
| rₛ | The Spearman coefficient, from −1 to 1. |
| Pearson correlation | The linear alternative, which Spearman becomes when applied to ranks. |
The inputs explained
| Field | What to enter |
|---|---|
| X values | X values, comma or space separated. |
| Y values | Y values, in the same order and the same count as X. |
When to use it
Working with ordinal data
Rankings, ratings and ordered categories have no meaningful arithmetic, so a rank-based measure is the correct choice.
Handling a curved relationship
Where the association is clearly monotonic but not linear, Spearman describes it properly and Pearson understates it.
Data with outliers
An extreme value becomes just the top rank, so it cannot distort the measure the way it distorts Pearson.
Worked examples
Every figure in the tables below is produced by this page’s own calculator at build time, so the numbers and the tool always agree. Select any row to load that scenario.
What does Spearman give for different relationships?
Perfect, moderate and perfectly inverse relationships.
| Y values (X = 1 to 6) | Spearman’s rs | Sum of squared rank differences | Strength |
|---|---|---|---|
| 6, 5, 4, 3, 2, 1 | -1.000 | 70.000 | Strong |
| 2, 1, 5, 3, 6, 4 | 0.6571 | 12.000 | Moderate |
| 1, 2, 3, 4, 5, 6 | 1.000 | 0 | Strong |
Questions
When should I use Spearman instead of Pearson?
When the data is ordinal, when the relationship is monotonic but curved, or when outliers would distort a Pearson correlation. Pearson remains preferable for genuinely linear relationships in interval data, where it uses more of the information available.
Can Spearman be 1 when Pearson is not?
Yes, and this is the key difference. Any strictly increasing relationship gives a Spearman of exactly 1, however curved. Pearson would report less than 1 for the same data because it measures departure from a straight line, not departure from consistent ordering.
How are ties handled?
Tied values share the average of the ranks they would have occupied. Two values tied for third and fourth both receive rank 3.5. The simple 1 − 6Σd² formula is technically exact only without ties, so with ties the calculation falls back to correlating the averaged ranks directly.
Does Spearman detect any relationship?
Only monotonic ones. A U-shaped relationship, where y falls then rises, can give a Spearman near zero despite y being perfectly determined by x. No single correlation coefficient detects all dependence, which is why plotting the data remains essential.
For the linear version, see the correlation coefficient calculator. For the unstandardised measure, see the covariance calculator.