Correlation
In clinical research we are often interested in whether two continuous measurements tend to change together. Does blood pressure rise with age? Does a longer hospital stay correlate with a higher infection risk score? Correlation analysis quantifies the strength and direction of the association between two variables, without assuming that one causes the other.
The Scatter Diagram
Before calculating any correlation coefficient, the first step is always to plot the data. A scatter diagram displays each observation as a single point, with one variable on the horizontal axis and the other on the vertical axis. The overall pattern of points reveals whether the association is positive, negative, linear, or curved — information that a single number cannot convey on its own.
The scatter diagram above shows a positive association between age and systolic blood pressure: older patients tend to have higher readings, though with considerable individual variation around the general trend.
MedCalc can produce scatter diagrams using its Scatter diagram procedure.
Pearson Correlation Coefficient
The Pearson correlation coefficient $r$ measures the strength and direction of the association between two continuous variables. It is defined as the ratio of the covariance of the two variables to the product of their standard deviations:
$$ r = \frac{\displaystyle\sum_{i=1}^{n}(x_i - \bar{x})(y_i - \bar{y})}{\sqrt{\displaystyle\sum_{i=1}^{n}(x_i - \bar{x})^2 \cdot \sum_{i=1}^{n}(y_i - \bar{y})^2}} $$The numerator — the sum of the products of deviations from the respective means — is called the covariance. When $x$ tends to be above its mean at the same time as $y$ is above its mean, most products are positive and the covariance is large and positive. When they move in opposite directions, the products are mostly negative. Dividing by the product of the two standard deviations rescales the covariance to the fixed range $[-1, +1]$, making the result comparable across datasets with different units and variability.
The coefficient always lies between $-1$ and $+1$:
- $r = +1$: perfect positive linear relationship — as $x$ increases, $y$ increases proportionally.
- $r = 0$: no linear association.
- $r = -1$: perfect negative linear relationship — as $x$ increases, $y$ decreases proportionally.
As a rough guide to interpretation:
- $|r| < 0.2$: negligible association
- $0.2 \leq |r| < 0.4$: weak association
- $0.4 \leq |r| < 0.6$: moderate association
- $0.6 \leq |r| < 0.8$: strong association
- $0.8 \leq |r| \leq 1.0$: very strong association
These thresholds are a rough convention, not a universal law. What counts as a "strong" correlation depends heavily on the field. In physics, a correlation below 0.99 might be considered disappointingly weak. In epidemiology or social science, a correlation of 0.5 between two complex biological variables may be remarkably high. A correlation must always be interpreted in the context of the subject matter, the measurement precision of the variables, and the purpose of the analysis.
Hypothesis Test
A correlation calculated from a sample will rarely be exactly zero even when there is no true association in the population, simply due to sampling variation. The hypothesis test addresses whether the observed $r$ is large enough to be unlikely under the null hypothesis $H_0: \rho = 0$ (where $\rho$ is the true population correlation). The test statistic is:
$$ t = r \sqrt{\frac{n - 2}{1 - r^2}} $$Under $H_0$, this statistic follows a $t$-distribution with $n - 2$ degrees of freedom. A significant $p$-value indicates that the observed correlation is unlikely to have arisen by chance from a population with no association.
An important caveat: with a large sample size, even a very small correlation — say $r = 0.08$ — can be statistically significant, yet be of no practical or clinical importance. Statistical significance tells us whether an association exists; it says nothing about whether it is large enough to matter. Always report the magnitude of $r$ alongside the $p$-value.
Assumptions
The Pearson coefficient requires:
- Both variables are continuous and approximately normally distributed.
- The relationship between the variables is linear — inspect the scatter diagram to verify.
- There are no influential outliers: a single extreme point can markedly inflate or deflate $r$.
Example: In a cohort of 120 adults, age and systolic blood pressure show a Pearson correlation of $r = 0.68$ ($p < 0.001$), indicating a strong positive linear association.
MedCalc computes the Pearson correlation coefficient and its confidence interval in its Correlation procedure.
Rank Correlation Coefficients
When the assumptions of normality or linearity are not met — for example with ordinal data, skewed distributions, or datasets containing outliers — rank-based correlation coefficients are preferred. Instead of the raw values, these methods operate on the of the observations.
Spearman's Rank Correlation Coefficient ($r_s$)
Spearman's $r_s$ is computed by assigning ranks to each variable separately and then applying the Pearson formula to those ranks. When there are no tied ranks, an equivalent simplified formula is:
$$ r_s = 1 - \frac{6 \displaystyle\sum_{i=1}^{n} d_i^2}{n(n^2 - 1)} $$where $d_i$ is the difference between the rank of $x_i$ and the rank of $y_i$. The interpretation of $r_s$ is identical to that of Pearson's $r$: it ranges from $-1$ to $+1$ with the same rough guide for strength.
Example: Pain scores (on an ordinal 0–10 scale) and analgesic dose are recorded for 30 patients. Because pain scores are ordinal, Spearman's $r_s$ is the appropriate measure; the result $r_s = 0.74$ ($p < 0.001$) indicates a strong positive association between pain intensity and dose.
Kendall's Rank Correlation Coefficient ($\tau$)
Kendall's $\tau$ is based on counting concordant and discordant pairs of observations. A pair $(i, j)$ is if the ordering of $x$ and $y$ agrees (both $x_i > x_j$ and $y_i > y_j$, or both smaller); it is if the orderings disagree.
$$ \tau = \frac{C - D}{\dfrac{1}{2}\, n(n-1)} $$where $C$ is the number of concordant pairs, $D$ the number of discordant pairs, and $\frac{1}{2}n(n-1)$ is the total number of pairs.
Kendall's $\tau$ tends to give smaller absolute values than Spearman's $r_s$ for the same dataset, but has preferable statistical properties when data contain many ties.
Example: Applied to the same pain-score data, Kendall's $\tau = 0.57$ — a smaller number than $r_s = 0.74$, but pointing to the same strong positive association.
MedCalc computes both Spearman's $r_s$ and Kendall's $\tau$ in its Rank correlation procedure.
Choosing Between the Coefficients
The choice depends on the nature of the data and what assumptions can be justified. When in doubt, inspecting the scatter diagram and checking for normality will usually point clearly to the right method.
- Use Pearson's $r$ when both variables are continuous, approximately normally distributed, and the scatter diagram shows a linear pattern.
- Use Spearman's $r_s$ when data are ordinal, non-normal, or contain outliers that cannot be removed.
- Use Kendall's $\tau$ when there are many tied ranks, or when a more robust estimate is preferred.
All three coefficients share an important limitation: they measure only monotonic associations — relationships where one variable consistently increases (or decreases) as the other increases. A U-shaped or inverted-U relationship, where values first rise then fall, can produce a correlation close to zero even when the two variables are strongly related. This is another reason why visual inspection of the scatter diagram must always precede any numerical analysis.
Important: Correlation measures association, not causation. A high correlation between two variables does not imply that one causes the other.
Correlation Is Not Suitable for Method Comparison
A common but serious mistake in clinical laboratory studies is to use the correlation coefficient to assess whether two measurement methods agree. The logic seems intuitive — if the two methods agree well, their values should correlate highly — but it is fundamentally flawed.
Consider two methods for measuring serum creatinine where Method B consistently reads exactly twice as high as Method A. The Pearson correlation is $r = 1.0$: perfect. Yet the two methods disagree at every single observation and are clearly not interchangeable. Conversely, a moderate correlation such as $r = 0.85$ tells us nothing about whether the differences between the methods are small enough to be clinically acceptable — it depends entirely on the range and variability of the measured values.
Correlation measures the strength of a linear relationship. Agreement requires that the differences between the two methods are small — a question that correlation cannot answer. The correct tool for method comparison is the Bland–Altman plot, which directly quantifies the bias and limits of agreement between two methods. Where the nature of systematic error needs to be further characterised, Passing–Bablok regression can supplement the Bland–Altman analysis.