1001Ferramentas
📊Calculators

Spearman Correlation (ρ)

Compute Spearman rank correlation ρ between X and Y lists.

ρ =

Spearman: rank correlation

To get Spearman's ρ you first turn each series into ranks, then run a Pearson correlation on those ranks. When there are no ties, the shortcut is ρ = 1 − 6·Σdᵢ² / (n(n² − 1)), with dᵢ being the rank difference of each pair. Take X = (1,2,3,4,5), Y = (5,6,7,8,7): the ranks of Y come out as (1,2,3.5,5,3.5), and the Σd² works out to ρ ≈ 0.82. The coefficient sits between −1 (perfect inverse monotonic) and +1 (perfect direct monotonic). Because it works on ranks it shrugs off outliers, and it still picks up non-linear monotonic relationships like logarithms or exponentials, the kind of thing Pearson tends to underrate since it only ever measures the linear part.

Applications

You'll see it across epidemiology, where it's the default for biomedical data that isn't normally distributed, and in psychometrics. Sports analysts use it to compare athlete rankings against medal counts, product teams to weigh star ratings against actual usage, and researchers to handle Likert surveys with their agree/disagree scales. Basically any ordinal data is fair game. If your sample is small, Kendall's τ is a reasonable alternative with stronger statistical properties.

FAQ

Spearman vs Pearson — when to choose? Pearson expects linearity and roughly normal data. Spearman asks only for monotonicity and is happy with ordinal data. So when you've got outliers or a distribution that's clearly not normal, Spearman is the safer bet.

What about ties? The simplified formula assumes there aren't any. When ties show up, fall back to the general formula, which is Pearson on ranks using average ranks for the tied values. Most stats libraries such as SciPy or R take care of this for you.

Does ρ = 0 mean independence? Not quite. It only tells you there's no monotonic relationship. Two variables can still be tightly linked in a non-monotonic way, a quadratic shape for instance, and yet land at ρ ≈ 0.

Related Tools