The Analyst's Path

Spearman rank correlation

Spearman rank correlation measures how closely two sets of values agree in rank order. It is the Pearson correlation of the two sets of ranks, so it picks up any steadily rising or falling relationship, and ordinal data or a single extreme value cause it no trouble. A large gap between the rank and raw correlations is itself informative: the relationship is monotone without being linear, or one or two observations are carrying the raw figure.

3 min readPart of Returns, Statistical Measures and the Discipline of InferenceOpen in course mode

Advertisement

Pearson correlation measures linear association and assumes the magnitudes mean something. When the data are ordinal, or when a single extreme value would dominate, replace the values by their ranks and correlate those instead. That is Spearman's rank correlation, and its general definition is exactly the Pearson correlation of the two rank vectors.

How do you calculate and test a Spearman correlation?

Ties are where the arithmetic gets interesting, and they are common in factor work because scores get rounded and rankings get bucketed. The rule is to give tied values the average of the ranks they span. Three names tied at a score of 0.61 occupying raw rank positions 5, 6 and 7 each receive rank 6.0; two tied at 0.45 in positions 3 and 4 each receive 3.5.

The shortcut formula that appears in every textbook,

ρ = 1 − 6Σd² / (n(n² − 1))

is derived under the assumption of no ties and is wrong when ties are present. On the ten-name panel of Worked example 8 it returns 0.948485 against a true 0.947804, an error of 0.00068. Small here, and not small in general: the discrepancy grows with the number and size of the tie groups, and a heavily bucketed factor score can produce tie groups of ten or twenty names. Use the shortcut only after confirming there are no ties, and use the general definition otherwise.

Test the result the same way you test a Pearson correlation:

t = ρ√((n − 2)/(1 − ρ²)) on n − 2 degrees of freedom

which gives 8.407647 on 8 degrees of freedom against a critical 2.306004, so a two-tailed p-value of 0.0000305. The same statistic on the raw Pearson correlation of 0.932493 would be a different number, and the two measures disagree by 0.0153 on this data. A large gap between rank and raw correlation is itself information: it says the relationship is monotone but not linear, or that one or two observations are carrying the raw number.

Advertisement

What are the nonparametric alternatives?

Rank methods belong to a wider family that makes no distributional assumption at all. The Wilcoxon signed-rank test replaces the paired t-test when the differences are not normal, the Mann-Whitney U test replaces the two-sample t-test, and a runs test checks a sequence for randomness. Each buys freedom from normality and pays in power: on genuinely normal data a nonparametric test needs more observations to detect the same effect. Reach for them when the parametric assumption is doubtful and the sample is small, which in finance is often.

Advertisement

Part of the course

This page is part of Returns, Statistical Measures and the Discipline of Inference (QM1.04), in Phase 12: Finance Plus, AI and the quant-code track. The module's flashcards and its quiz are in the app.