Spearman’s rank correlation coefficient
Intermediate
What you need first. Nothing else on this path comes first. This page is part of Data analysis.
In statistics, the Spearman’s rank correlation coefficient is a measure of agreement between two rankings, on a scale from -1 to +1. A straight-line correlation asks how tightly two numerical measurements rise together. When the information is the order of the values rather than their spacing, the matching summary uses the ranks. That summary is Spearman’s rank correlation coefficient, a nonparametric measure of the relation between two sets of data.
The ordinary correlation also lies between and , and it describes the strength of a linear relationship between the values themselves rather than between their ranks.[1][2]
Spearman’s rank correlation coefficient
| Fact | Value |
|---|---|
| Topic | Data analysis |
| Listed on | Data analysis |
| Worked example | 1 |
Motivating example
Four students are ordered by hours of practice, 1 through 4, and separately by the judge’s ranking of a performance. If the performance order is the same as the practice order, the two rankings agree completely. If the performance order is exactly reversed, they disagree completely. A coefficient that is in the first case and in the second is tracking the agreement of the ranks, not the size of the gaps between hours. A monotone curve that is not a straight line can still produce a large rank coefficient, because the original units have been discarded on purpose.[1][2]
Intuition
Replace each measurement by its place in line: rank 1 for the smallest, rank 2 for the next, up to rank . Where the places agree, the rank differences are near zero and the coefficient is near . Where a high place on one variable is a low place on the other, the coefficient is near . Positive association, in the rank sense, means large values of one variable tend to sit with large values of the other. Negative association means large values of one tend to sit with small values of the other. The coefficient is then a description of that monotone agreement, and a test asks whether an association of that size is surprising if the two rankings are independent.[1]
Definition
For paired samples , let be the rank of among the values, with rank 1 on the smallest, and let be the rank of . Tied values receive the average of the ranks they share, so every rank is a midrank. Spearman’s rank correlation coefficient is the Pearson correlation of the two rank vectors: the ordinary correlation computed on the and the in place of the original values.
When neither sample has ties, the ranks are a permutation of and that correlation reduces to the shortcut
where . The shortcut is justified only in that no-ties case. A single tie group already breaks it: for values and values , the midranks of are , their correlation with the ranks is , and the shortcut gives .
With ties, the midrank correlation can be written
where and subtract a term in the cubed tie-group sizes from ; they are the sums of squared deviations of the two midrank vectors about their mean. With no ties, each observation is a group of size 1 and , which brings this expression back to the shortcut. If one sample is constant, its rank vector is constant too, the correlation has a zero denominator, and the coefficient is undefined. Charles Spearman, a psychologist, introduced the rank coefficient in 1904. It is one of the oldest rank statistics, and it is often called Spearman’s .[1]
Properties
The coefficient lies between and . If the ranks agree, every is 0, the sum of squares is 0, and . If the ranks are perfectly reversed, the sum of squared differences reaches the value that makes . A value near zero is the case of no rank association. A value near says the orderings agree. It does not say that the relationship is a straight line with slope 1 in the original units, because those units were replaced by ranks.[1][2]
The coefficient is used as a test of independence between the two rankings. The bilateral null says the variables are mutually independent, against a positive or a negative association. A one-sided null keeps only one of those directions. Critical values come from the null distribution of the coefficient, tabulated for small . The letter used for those critical values is not a Student . As a nonparametric measure it applies to data that can be ordered, including ordinal codes whose gaps are not lengths, as well as to numerical data that have been replaced by ranks. The associated test does not assume a shape for the population distribution. When the scientific question is specifically about a straight line, the correlation of the original values is the matching summary, and a residual plot is the check that a line was appropriate.[1][2]
Worked example
Four pairs have ranks and ranks . The differences are . The squared differences are , and they sum to 2. Here , so
Your turn. The ranks are replaced by , a complete reversal, and the ranks stay . What is ?
The differences are . The squared differences sum to . Then .
Assumptions and limits
The shortcut formula treats the ranks as a permutation, which they are only when there are no ties. With ties, average ranks are inserted and the coefficient is the correlation of those midranks, the and expression in the Definition; it is then no longer the plain function of the alone, and even one tie group is enough to move it off the shortcut value. A sample whose values are all equal has a constant rank vector, and for it the coefficient is undefined rather than zero. Independence of the two rankings is the null of the test, not a finding the coefficient reports by itself. The coefficient does not estimate a slope in the original units. A transformation that preserves order does not change it. A transformation that changes order can change the coefficient, but need not: reversing just one nonconstant rank vector negates , so a zero coefficient stays zero. Observations that cannot be placed in an order at all, with no criterion that says which comes first, are outside the construction: the ranks have to be defined before is.[1]
Connections
Correlation is the linear measure on the original values, the that OpenIntro defines from the standardised products and . Levels of measurement explain why an ordinal code is a candidate for ranks rather than for a mean. The variable is what gets ranked. A statistical model for a straight line is a different summary, one that keeps the spacing. Ranking is the replacement of each observation by its place, which is the first step of the coefficient.[2][1]
Check yourself
Try these questions before opening an answer.
Mild disagreement
Rank differences are 0, 0, -1, and 1, so the squared differences sum to 2, and n = 4. What is the coefficient?
The coefficient is 0.8.
Complete reversal
The squared rank differences for a complete reversal of four ranks sum to 20. What is the coefficient?
The coefficient is -1.
See also
Line chart · Apriori algorithm · Asymptotic analysis · Average treatment effect · Base rate · Bayesian inference · Bayesian model · Bayesian probability
References
- ^ a b c d e f g h i a. (p. 502) b. (pp. 502–503) c. (pp. 502–503) d. (p. 502) e. (p. 503) f. (pp. 502–503) g. (p. 502) h. (pp. 502–503) i. (p. 502) Dodge, Yadolah (2008). The Concise Encyclopedia of Statistics. Springer. https://doi.org/10.1007/978-0-387-32833-1
- ^ a b c d e a. (Ch. 8, §8.1.4) b. (Ch. 8, §8.1.4) c. (Ch. 8, §8.1.4) d. (Ch. 8, §8.1.1, §8.1.3, §8.1.4) e. (Ch. 8, §8.1.1, §8.1.4) Diez, D. M., Çetinkaya-Rundel, M. & Barr, C. D. (2019). OpenIntro Statistics (4th ed.). OpenIntro. https://www.openintro.org/book/os/
Cite this page
StatWiki (2026). "Spearman's rank correlation coefficient." StatWiki. Last updated 2 December 2026. https://www.statwiki.io/articles/spearman-s-rank-correlation-coefficient.html
@misc{statwiki_spearman_s_rank_correlation_coefficient,
author = {{StatWiki}},
title = {{Spearman's rank correlation coefficient}},
year = {2026},
url = {https://www.statwiki.io/articles/spearman-s-rank-correlation-coefficient.html},
urldate = {2026-12-02},
note = {StatWiki, last updated 2 December 2026}
}