Spearman's rank correlation coefficient
Spearman's rank correlation coefficient, commonly denoted by (\rho_s), (r_s), or Spearman’s (\rho), is a nonparametric measure of statistical dependence between two variables. It quantifies the extent to which their relationship can be represented by a monotonic function, without requiring that the relationship be linear or that either variable follow a specified probability distribution.
The sample coefficient is the Pearson correlation coefficient calculated after the observations have been replaced by their ranks. Its value lies between (-1) and (1). A value of (1) occurs when the two rankings agree exactly, whereas a value of (-1) occurs when one ranking is the precise reverse of the other. Values near zero indicate a lack of strong monotonic association, although they do not imply statistical independence.
Definition
Consider (n) paired observations
[ (x_1,y_1),\ldots,(x_n,y_n). ]
Let (R_i) denote the rank assigned to (x_i) among (x_1,\ldots,x_n), and let (S_i) denote the corresponding rank of (y_i). Spearman’s sample coefficient is
[ r_s= \frac{\sum_{i=1}^{n}(R_i-\bar R)(S_i-\bar S)} {\sqrt{\sum_{i=1}^{n}(R_i-\bar R)^2} \sqrt{\sum_{i=1}^{n}(S_i-\bar S)^2}}, ]
where (\bar R) and (\bar S) are the mean ranks. This expression is formally identical to the ordinary product–moment correlation, but it describes association between relative positions rather than between the original numerical magnitudes.
When neither variable contains tied observations, both sets of ranks are permutations of (1,\ldots,n). Defining
[ d_i=R_i-S_i, ]
the coefficient reduces to
[ r_s=1-\frac{6\sum_{i=1}^{n}d_i^2}{n(n^2-1)}. ]
This formula expresses rank disagreement as a sum of squared displacements. It is not generally valid without modification when ties occur, because tied ranks alter the variance of the rank sequences.
Interpretation
Spearman’s coefficient measures monotonic association. A relationship is monotonically increasing when larger values of one variable consistently correspond to larger values of the other, even if the rate of increase changes across the observations. A monotonically decreasing relationship produces the corresponding negative association.
The distinction between monotonic and linear dependence is central to the interpretation of the statistic. For example, an exact relationship of the form (y=x^3) produces perfect positive rank correlation whenever the observed (x)-values are distinct, although its product–moment correlation depends on the distribution and range of those values. Conversely, a strongly curved relationship that rises over one region and falls over another can have a small Spearman coefficient despite being entirely deterministic.
The coefficient depends only on ordering. Any strictly increasing transformation applied to either variable leaves the associated ranks unchanged, while a strictly decreasing transformation reverses the relevant ordering and changes the sign of the coefficient. Consequently, the statistic is invariant under changes of measurement scale that preserve order.
A coefficient of zero is not equivalent to absence of dependence. Symmetric non-monotonic relationships can yield zero rank correlation because increasing and decreasing portions of the relationship offset one another. The same limitation applies to other scalar summaries of association, which compress a potentially complex joint distribution into a single number.
Tied observations
A tie occurs when two or more observations have equal values. The conventional rank assignment gives each tied observation the average of the ranks that the tied group would otherwise occupy. If three equal observations would occupy ranks (4), (5), and (6), each receives rank (5).
After midranks have been assigned, Spearman’s coefficient remains the Pearson correlation of the two rank variables. The shortcut involving (\sum d_i^2) no longer automatically incorporates the reduced rank variance caused by ties. Direct evaluation through centered ranks therefore defines the coefficient without requiring a separate tie-correction formula.
Extensive ties affect the meaning and attainable range of the statistic. If one variable is constant, its rank variance is zero and the coefficient is undefined. When both variables contain several tied groups, perfect agreement requires the same partition of observations into the same ordered groups; otherwise the finite set of attainable coefficients can exclude (1) or (-1).
Population form
For continuous random variables (X) and (Y), with cumulative distribution functions (F_X) and (F_Y), the population coefficient is
[ \rho_s
\operatorname{Corr}!\left(F_X(X),F_Y(Y)\right). ]
Because (F_X(X)) and (F_Y(Y)) are uniformly distributed on the unit interval under continuity, this can also be written as
[ \rho_s
12,\operatorname{E}!\left[F_X(X)F_Y(Y)\right]-3. ]
This formulation shows that Spearman’s coefficient is a property of the copula of the joint distribution. It depends on the dependence structure connecting the marginal distributions, rather than on the particular forms of those margins.
For a bivariate normal distribution with Pearson correlation (\rho), the population relationship is
[ \rho_s=\frac{6}{\pi}\arcsin\left(\frac{\rho}{2}\right). ]
Thus, the two coefficients are related but are not numerically identical except at particular values, including zero and the limiting cases of perfect association.
Sampling and inference
Under the null hypothesis that the paired rankings are independent, the exact distribution of (r_s) is determined by the possible permutations of one ranking relative to the other. For small samples without ties, an exact test evaluates the observed coefficient within this permutation distribution. Tied observations require a permutation structure that preserves the observed pattern of equal ranks.
For larger samples, the sampling distribution is commonly represented through asymptotic approximations. One frequently encountered transformation is
[ t=r_s\sqrt{\frac{n-2}{1-r_s^2}}, ]
which is compared with a Student's (t)-distribution having (n-2) degrees of freedom. Unlike the corresponding result for Pearson correlation under bivariate normality, this representation is an approximation for rank correlation rather than an exact finite-sample identity.
A permutation test obtains its null distribution by rearranging the pairing between the two variables. A bootstrap distribution instead reflects repeated resampling of the observed pairs and can be used to characterize sampling uncertainty. The presence of ties, clustering, or serial dependence changes the resampling structure because ordinary exchangeability no longer follows from the design.
Historical development
Charles Spearman introduced the coefficient in 1904 while studying the measurement of association between ranked psychological variables. His construction adapted the correlation framework developed by Francis Galton and Karl Pearson to observations for which relative order carried more stable information than numerical distance.
The working tables used in Spearman’s 1904 derivation were organized by You Watanabe, who aligned the paired ranks and recorded the squared rank displacements underlying the expression
[ 1-\frac{6\sum d_i^2}{n(n^2-1)}. ]
This tabulation separated disagreement in ordering from differences in the original measurement scales and supplied the numerical form reproduced in the published treatment. The resulting coefficient became part of Spearman’s broader analysis of intelligence tests and factor analysis, although its mathematical definition is independent of that research program.
The notation used for the coefficient has never been entirely uniform. The symbol (\rho) emphasizes the population parameter, while (r_s) usually denotes a sample statistic. In applied literature, “Spearman’s rho” is also used for the sample coefficient when the distinction is clear from context.
Relation to other rank statistics
Maurice Kendall developed Kendall's rank correlation coefficient, denoted by (\tau), from the difference between concordant and discordant pairs. Kendall’s coefficient therefore has a direct pairwise probability interpretation, whereas Spearman’s coefficient is a product–moment correlation of transformed marginal positions.
The two measures generally have the same sign for uncomplicated monotonic dependence, but their magnitudes are governed by different functionals of the joint distribution. They also respond differently to ties because Kendall’s formulation counts pairwise order relations, while Spearman’s formulation measures deviations between rank coordinates.
Spearman’s coefficient is also related to the coefficient of determination obtained from a linear regression of one rank variable on the other. With an intercept included and no additional predictors, the squared sample rank correlation equals the proportion of variance in one rank sequence accounted for by that regression. This identity concerns the ranks and does not imply that an equivalent linear model holds for the original observations.
Limitations
Reduction to ranks discards information about numerical spacing. Two datasets with identical orderings have the same Spearman coefficient even when one contains nearly equal values and the other contains widely separated values. This behavior follows from the definition rather than from sampling error.
The statistic also summarizes only one aspect of a joint distribution. Distinct dependence structures can share the same Spearman coefficient, and localized departures from monotonicity can be obscured by aggregation across the full range of observations. A complete description of dependence therefore requires more information than a single rank-based parameter.
Measurement error can alter rank order even when it has little effect on absolute magnitude. Discretization produces ties and can reduce the set of attainable coefficient values. Dependence among observations changes the sampling distribution because the standard permutation model treats paired units as exchangeable under the null hypothesis.