statforclinicians

Spearman rank correlation

Measures how strongly two measurements move together using ranks, so skew and curves that keep one direction (monotone) are fine.

Statistically reviewed by Daniel Wolff on 5 November 2026.

Clinical example

How strongly a pain score from 0 to 10 and the number of analgesic doses are related. Both variables have many tied values (see ties). Also check when each was measured: doses given in response to pain measured later would weaken the interpretation.

When to use it

  • You have two measurements per patient and want to know how strongly they move together.
  • The variables are skewed or ordered scores, or the relationship is monotone: it keeps going one way, even if it curves. Spearman's ρ (also written r_s) measures monotone association.
  • You describe an association. You are not showing that two methods give the same values.
  • Correlation describes association only. For the size of the change per unit, or to adjust for a confounder, use regression.

Assumptions to check

A monotone relationship

It should always rise or always fall, not both. Plot a scatter diagram first. A U-shaped or inverted-U relationship can leave ρ near 0: use regression with a curved term, for example a spline.

At least ordinal data

Both variables need an order that means something. Only the ranks are used, so the distances between values do not matter.

Ties

Many tied values, as with a 0 to 10 pain score or a count of doses, reduce the information in the ranks. ρ is still valid, computed on average ranks, but with heavy ties and a small sample Kendall's tau-b is often preferred.

Outliers

Ranks reduce the influence of outliers but do not remove it. One patient who is extreme on both variables still pulls ρ.

Independent observations

One pair of values per patient. Several measurements per patient need repeated-measures correlation or a mixed model.

What to report

  • ρ with its 95% CI, and a scatter plot
  • The number of complete pairs actually analyzed
  • The exact p-value. It only tests whether ρ = 0, which is rarely the interesting question

Common mistakes

Correlation is not causation

A correlation shows that two measurements go together, not that one causes the other. A confounder such as age often drives both.

Correlation doesn't show agreement

Two methods can correlate perfectly and still disagree systematically. Use a Bland-Altman plot.

Plot the data before you report a correlation

A coefficient near 0 can hide a U-shaped relationship, and a single extreme patient can create or destroy a correlation. Look at the scatter plot.

Mind the range of your sample

A correlation depends on how spread out the sample is. Studying only hypertensive patients gives a lower coefficient for the same underlying relationship, so comparing correlations between studies with different populations is misleading.

Significant is not strong

With a large sample, a tiny correlation is significant. Report the coefficient with its 95% CI. The p-value only tests whether the coefficient is 0.

Don't pool different subgroups blindly

Pooling, for example men and women or two hospitals, can create or hide a correlation.

Repeated measurements aren't independent

Treating several measurements per patient as separate patients makes confidence intervals too narrow and p-values too small.

Reading ρ as if it described the raw values. It is the correlation of the ranks, so ρ² is not the share of variance in the original measurements.

Alternatives

If your situation is…Use
Both variables are roughly normal, with a straight-line relationshipPearson correlation
You want the size of the change, need to adjust for other variables, or the relationship is U-shaped (regression with a curved term). Use ordinal logistic regression for an ordered outcome, and Poisson or negative binomial regression for counts such as dosesLinear regression
Several measurements per patient (repeated-measures correlation, or a mixed model)Linear mixed model
You actually want to show that two methods give the same valuesBland-Altman plot and ICC

In your software

R
# R
plot(d$pain, d$doses)
# exact = FALSE: with tied values an exact p-value cannot be computed
res <- cor.test(d$pain, d$doses, method = "spearman", exact = FALSE)
res   # rho is the estimate; S is the test statistic and can be ignored
sum(complete.cases(d$pain, d$doses))   # pairs analyzed: incomplete pairs are dropped silently
# cor.test gives no CI for rho. A bootstrap interval:
set.seed(1)
ok <- complete.cases(d$pain, d$doses)
x <- d$pain[ok]; y <- d$doses[ok]
boot <- replicate(2000, {
  i <- sample(length(x), replace = TRUE)
  cor(x[i], y[i], method = "spearman")
})
quantile(boot, c(0.025, 0.975), na.rm = TRUE)   # 95% CI for rho
# With many ties and a small sample, Kendall's tau-b:
cor.test(d$pain, d$doses, method = "kendall", exact = FALSE)
SPSS
* Spearman's rho is the correlation, Sig. (2-tailed) is the p-value, and N is the number of pairs.
* NOSIG flags significant correlations with asterisks. For Kendall's tau-b use /PRINT=KENDALL.
* NONPAR CORR prints no CI. Use a bootstrap interval, for example in R.
NONPAR CORR
  /VARIABLES=pain doses
  /PRINT=SPEARMAN TWOTAIL NOSIG.

Sources

A confidence interval for ρ

cor.test gives no confidence interval for Spearman’s ρ. A bootstrap confidence interval resamples the patients and is the easiest way to get one. It is approximate, and it does not rescue a very small sample.