Spearman's Rank Correlation
Spearman Correlation: Association After Replacing Values with Ranks
Spearman's rank correlation, usually written rho, measures whether larger values of one variable tend to accompany larger or smaller values of another.
Replace each variable by its ranks, then calculate the ordinary correlation of the two rank lists. Because ranks preserve order rather than spacing, Spearman correlation is suited to ordinal data and to relationships that are monotonic but curved.
When there are no ties, the shortcut rho = 1 - 6 sum d squared divided by n(n squared - 1) is available, where d is the difference between paired ranks.
With ties, assign each tied observation its average of the ranks it would occupy, then compute correlation on those ranks; the no-tie shortcut should not be used unchanged.
A rho near +1 means nearly matching order, a rho near -1 means nearly reversed order, and a value near zero says there is little monotonic rank association in that sample.
Rank correlation is invariant to strictly increasing transformations. Changing a variable from one unit scale to another or applying a strictly increasing transform leaves the rank order unchanged.
That robustness does not turn correlation into causal evidence: confounding, selection, and time order still matter. Also, a strong nonmonotonic pattern can have rho near zero because rising and falling portions cancel in rank association.
Four observations have X ranks 1, 2, 3, 4 and paired Y ranks 4, 2, 3, 1. With no ties, what is Spearman's rho?
In a Spearman analysis, three observations are tied for values that would otherwise occupy ranks 5, 6, and 7. What rank should each tied observation receive?