Skip to content
Omnikalc

Spearman correlation calculator: how strongly do two rankings agree?

Enter the number of pairs and the sum of squared rank differences to get Spearman's rho, its t statistic, the p-value and a confidence interval.

Updated on
Your inputs

Value out of range

Value out of range

Results

Spearman's rank correlation (ρ)

0.855

Very strong monotonic relationship
t statistic
4.654
p-value (two-sided)
0.0016
Shared rank variance (ρ²)
0.730
95 % confidence interval: lower
0.386
95 % confidence interval: upper
0.973

Spearman’s rank correlation measures how well the ranking of one variable matches the ranking of another. The Spearman correlation calculator takes the number of pairs and the sum of squared rank differences, and gives Spearman’s ρ, the t statistic, the p-value, ρ² and a 95 % confidence interval.

How the calculation works

  • Rank each variable from smallest to largest, giving tied values the average of their ranks. For every pair, take the difference d between the two ranks.
  • Square the differences and add them to get Σd². This is the number you enter, with the number of pairs n.
  • ρ = 1 − 6 × Σd² ÷ (n × (n² − 1)). It is +1 for a perfect increasing relationship, −1 for a perfect decreasing one and near 0 for none.
  • The t statistic is ρ × √((n − 2) ÷ (1 − ρ²)) with n − 2 degrees of freedom, which gives the p-value. The confidence interval uses the Fisher transformation with the Bonett and Wright standard error.

Example

Ten students are ranked on hours of study and on exam score, and the squared rank differences add up to Σd² = 24. Then ρ = 1 − 6 × 24 ÷ (10 × 99) = 0.855. The t statistic is 4.654 with 8 degrees of freedom, so the p-value is about 0.0016. The 95 % confidence interval runs from 0.386 to 0.973, which indicates a very strong relationship.

Why it matters

Many data, such as survey ratings, rankings and skewed measurements, do not suit Pearson’s correlation. Spearman’s coefficient works on ranks, so it is robust to outliers and to curved but steady relationships, and it is simple to compute by hand.

Good to know

The formula is exact when there are no tied ranks. The p-value uses a t approximation that is good for samples of about 10 or more, and exact tables are used for very small ones. The confidence interval uses the Bonett and Wright variance, and with 4 pairs or fewer the result is not reliable.

The correlation significance calculator tests Pearson’s r, and the Mann-Whitney U calculator compares two groups by ranks.

Frequently asked questions

When should I use Spearman instead of Pearson?

Use Spearman when the data are ranks, when the relationship is steadily increasing or decreasing but not a straight line, or when outliers or skewed values would distort Pearson's coefficient. It measures a monotonic relationship, based only on the order of the values.

How do I handle ties?

Give tied values the average of the ranks they would have taken. The shortcut formula based on Σd² is exact only when there are no ties and is a good approximation when there are few. With many ties, compute the Pearson correlation of the ranks.

What counts as a strong correlation?

A common guide calls an absolute value above 0.8 very strong, 0.6 to 0.8 strong, 0.4 to 0.6 moderate and 0.2 to 0.4 weak. The scale depends on the field, and the sample size matters for the p-value, since a small correlation can be significant in a large sample.

Does a strong correlation mean one variable causes the other?

No. A correlation shows that two variables move together in rank, but not why. Another variable may drive both, or the link may be a coincidence. Causation needs a study design that can show it.

Was this calculator helpful?

Thanks for your feedback!

Results are estimates provided for information purposes. They do not replace professional advice.