Pearson vs Spearman correlation: differences and when to use each
A correlation coefficient measures how closely two quantities move together. The two in everyday use are Pearson’s r, for linear relationships, and Spearman’s ρ, for monotonic relationships based on ranks. On the same data they can differ a lot, and the choice can change the conclusion. This guide shows the difference with numbers and plots, then covers confidence intervals, P values at small n, and reporting.
Calculate a correlation on your own dataPaste X and Y: r, ρ, P values, 95% CI of r, a scatter plot and a results sentence.Calculate →The difference in one line
- Pearson’s r uses the values themselves and measures the strength of a linear relationship; it is sensitive to outliers
- Spearman’s ρ replaces values by ranks and then computes Pearson’s r; it measures a monotonic relationship (one goes up as the other goes up) and is robust to outliers and curvature
- Both run from −1 to 1: 0 means no relationship, ±1 a perfect one (a straight line for Pearson, perfectly matching ranks for Spearman)
- Correlation does not mean that one causes the other
Pearson’s r is the sum of products of deviations divided by the square root of the product of the sums of squared deviations:
In the app’s sample (mRNA vs protein, n = 14, made up), r = 0.91 (95% CI 0.74 to 0.97) and ρ = 0.96: both show a strong positive correlation. With clean data like this the two barely differ. They part ways in cases like these:
Outliers and curves change the picture
| Data | n | Pearson r | P | Spearman ρ | P |
|---|---|---|---|---|---|
| Sample (mRNA vs protein) | 14 | 0.912 | 5.5 × 10−6 | 0.960 | 5.1 × 10−8 |
| Outlier example (left) | 10 | 0.874 | 9.3 × 10−4 | 0.236 | 0.51 (exact) |
| Same, outlier removed | 9 | −0.048 | 0.90 | −0.050 | 0.91 (exact) |
| Saturating curve (right) | 8 | 0.858 | 0.0064 | 1.000 | 5.0 × 10−5 (exact) |
On the left, nine unrelated points (r = −0.05) become a “significant strong correlation”, r = 0.87, P = 9.3 × 10−4, by adding one point. Pearson’s r multiplies distances from the mean, so a single distant point can dominate. For Spearman that point only carries the information “largest x and largest y”, one rank’s worth, so ρ = 0.24 (P = 0.51): it changes much less and is not significant.
On the right it is the other way round: the relationship is perfect, yet r is not 1. Responses that saturate with dose or time, or that grow exponentially, suit Spearman, or Pearson after a log transform. In both cases, look at the scatter plot first.
When to use which
95% confidence interval of r (Fisher’s z)
Because r is bounded by −1 and 1 its distribution is skewed, so the interval is built on Fisher’s z = atanh(r) scale and transformed back:
| n | 95% CI for r = 0.5 | P (r = 0) |
|---|---|---|
| 5 | −0.68 to 0.96 | 0.39 |
| 10 | −0.19 to 0.86 | 0.14 |
| 20 | 0.07 to 0.77 | 0.025 |
| 50 | 0.26 to 0.68 | 2.2 × 10−4 |
| 100 | 0.34 to 0.63 | 1.2 × 10−7 |
With n = 10 and r = 0.5, the 95% CI spans everything from a weak negative to a fairly strong positive correlation. Reporting the interval, not just r, tells readers how much the data can support.
Spearman at small n: exact P
For large n, Spearman’s P uses the same t approximation as Pearson’s. For small n, the exact P from counting all n! orderings of the ranks is more reliable. BenchFig reports the exact P for n ≤ 10 without ties.
| n | Orderings n! | Smallest two-sided P (ρ = ±1) |
|---|---|---|
| 3 | 6 | 0.33 |
| 4 | 24 | 0.083 |
| 5 | 120 | 0.017 |
| 6 | 720 | 0.0028 |
| 7 | 5,040 | 4.0 × 10−4 |
| 8 | 40,320 | 5.0 × 10−5 |
| 10 | 3,628,800 | 5.5 × 10−7 |
With n = 4, even perfectly matching ranks give P = 2/24 = 0.083, which cannot reach 0.05; with n = 3 it is 0.33. A correlation on 3 or 4 points can hardly support any test.
Correlation vs causation, and other pitfalls
- Correlation is not causation: a correlation cannot tell whether x raised y, y raised x, or a third factor (cell number, body size, age) moved both
- Pooling groups creates correlations: putting wild-type and knockout animals on one scatter plot can produce a correlation from the group difference alone. Compute it per group, or plot the groups separately
- Points must be independent: repeated measurements of the same animal, or technical replicates, as separate points inflate n
- A narrow range weakens r: if x covers only a narrow range (similar animals), even a strong relationship gives a small r
- r² is the share of the variation in y explained by the line: r = 0.5 means 25%. Fitting the line is covered in linear regression and R²
Correlation coefficient and P value in Excel
With x in A2:A15 and y in B2:B15 (Excel 2010 or later). For the n = 14 sample, these values match SciPy’s pearsonr and spearmanr.
| Quantity | Excel formula | Sample value |
|---|---|---|
| Pearson’s r | =CORREL(A2:A15,B2:B15) (in F2; =PEARSON(…) is the same) | 0.9121 |
| n | =COUNT(A2:A15) (in F3) | 14 |
| t | =F2*SQRT((F3-2)/(1-F2^2)) (F2 = r) | 7.709 |
| Two-sided P | =T.DIST.2T(ABS(F4),F3-2) (F4 = t) | 5.5 × 10−6 |
| Spearman’s ρ | Fill =RANK.AVG(A2,$A$2:$A$15,1) in C and =RANK.AVG(B2,$B$2:$B$15,1) in D, then =CORREL(C2:C15,D2:D15) | 0.9604 |
- The Analysis ToolPak “Correlation” tool returns only the matrix of r, with no P values or confidence intervals.
- RSQ returns r² (the coefficient of determination), not r.
How to write it in a paper
Methods: “Correlation was assessed by Pearson’s correlation coefficient r, with 95% confidence intervals from Fisher’s z transformation.” For Spearman: “Correlation was assessed by Spearman’s rank correlation coefficient ρ (exact P for n ≤ 10 without ties, otherwise the t-distribution approximation).”
Results: “mRNA and protein levels were strongly positively correlated (Pearson r = 0.91, 95% CI 0.74–0.97, n = 14, P < 0.001).” Always give n and show the scatter plot. General formats are in how to report statistics.
FAQ
Can I report both Pearson and Spearman?
Yes, but decide in advance which is the main result, and do not compute both and report only the significant one. Show a scatter plot either way so readers can see the shape of the relationship.
Is r = 0.3 a “weak” correlation?
Cohen’s rough benchmarks of 0.1, 0.3 and 0.5 for small, medium and large exist, but what matters depends on the field and the measurement. Judge practical usefulness from the width of the 95% CI and the scatter plot rather than the number alone.
Can I use several measurements from the same animal as separate points?
They are not independent, so the P value comes out too small. Use one mean per animal, compute a correlation within each animal and combine them, or use repeated-measures correlation or a mixed model.
Is the Spearman P exact when there are many ties?
With ties, BenchFig reports the t-distribution approximation (as SciPy’s spearmanr does). With many ties and small n the approximation can be rough; say so in the Methods, or check with software that runs a permutation test.
Related guides
Product and journal names are trademarks or registered trademarks of their respective owners.