Spearman's rank correlation

Analytika TeamLast reviewed 7 min read

Spearman’s rank correlation coefficient (Spearman, 1904) is the most common alternative to Pearson’s r. By working with ranks rather than raw values, it captures relationships that rise or fall steadily without following a straight line, and it isn’t thrown off by a few extreme values.

How it works

  1. Rank each variable separately, from smallest to largest. Ties get the average rank.
  2. Calculate Pearson’s correlation between the two sets of ranks.

Because only the order matters, any steadily increasing curve gives ρ = 1, even an exponential one. Outliers lose their pull, because the largest value is simply ranked last, however extreme it is.

When to use Spearman instead of Pearson

  • Ordinal data: rankings, single rating items, education levels.
  • Skewed variables, such as income or reaction times.
  • Outliers that are genuine but would dominate Pearson’s r.
  • Monotonic but curved relationships.

Worked example: temperature and ozone

R’s airquality data record daily ozone and temperature in New York, May to September 1973. Is ozone related to temperature? 116 days have both measurements.

Step 1: check the assumptions for Pearson

Ozone is strongly right-skewed (it fails the normality check), and a Ramsey RESET test shows the relationship is curved (p < .01): ozone rises slowly at moderate temperatures and steeply on hot days. Both point to Spearman, which is what Analytika chooses.

Step 2: run the test

Analytika engine output
Spearman rho: 0.7740
P-value: 2.248e-24
N: 116
df: 114
95% CI: [0.6890, 0.8381]
Influential points (Cook's D > 4/n): 4
Spearman rho (excl. influential): 0.8115
P-value (excl. influential): 1.99e-27
Rows excluded for missing values: 37 of 153
R 4.6 output
> cor.test(airquality$Ozone, airquality$Temp, method = "spearman", exact = FALSE)

	Spearman's rank correlation rho

data:  airquality$Ozone and airquality$Temp
S = 58778, p-value < 2.2e-16
sample estimates:
     rho
0.774043

The same ρ. R prints p only down to 2.2 × 10⁻¹⁶. Analytika’s Spearman template is checked against R on every change.

Step 3: interpret

  • ρ = .77, 95% CI [.69, .84], p < .001: a strong positive association. Hotter days tend to have higher ozone.
  • For comparison, Pearson’s r on the same data is .70. It understates the association, because it’s judging how well a straight line fits a curved relationship.
  • Four days have a large influence on the fit. Without them ρ = .81, so the conclusion doesn’t depend on them.

Step 4: report it (APA 7)

Because ozone was skewed and its relationship with temperature non-linear, Spearman’s rank correlation was used. Temperature and ozone were strongly positively correlated, rs(114) = .77, p < .001, 95% CI [.69, .84].

APA style writes Spearman’s correlation as rs (or ρ), with N − 2 in brackets. These are observational data: temperature and ozone share causes such as sunshine, so this is an association, not proof that heat causes ozone.

Spearman vs Kendall’s tau

Kendall’s τ is another rank correlation, based on counting pairs that agree or disagree in order. It handles many ties well and has a more intuitive probability reading, but it’s typically smaller in magnitude than ρ for the same data. Don’t compare a τ from one study with a ρ from another.

Common mistakes

  • Using Spearman to fix a non-monotonic relationship, such as a U-shape. Neither coefficient captures that. Plot the data.
  • Running both and reporting the stronger one. Choose from the checks.
  • Reading ρ as a linear slope. It describes the strength of a monotonic trend, not a rate of change.

How to run it

  • SPSS: Analyze → Correlate → Bivariate, then tick Spearman.
  • R: cor.test(x, y, method = "spearman")
  • Python: scipy.stats.spearmanr(x, y)
  • Analytika: ask whether two variables are related. It checks normality and linearity, chooses Pearson or Spearman, and explains why. Our free correlation calculator shows both side by side.

References

  • Spearman, C. (1904). The proof and measurement of association between two things. The American Journal of Psychology, 15(1), 72–101.

More in Correlation

Try it with the free tools

Run this on your own data

Upload a dataset and ask your question in plain English. Analytika checks the assumptions, picks the test, runs it, and writes the results up in APA format.

Try it free