Guides  /  correlation

Correlation: a complete guide, with worked examples

Correlation is the most widely used and most widely over-interpreted statistic in research. This guide explains what r actually measures, how to choose between Pearson and Spearman, works a coefficient out by hand, shows what r squared adds, and sets out the interpretation and reporting that examiners look for.

Hafiz Ahmad Tariq Written and reviewed by Hafiz Ahmad Tariq, Senior Biostatistician
Updated 17 August 202618 min read
What is correlation?

Correlation measures the strength and direction of the association between two variables. It is expressed as a coefficient between −1 and +1: values near +1 indicate that high scores on one variable accompany high scores on the other, values near −1 indicate the opposite, and values near 0 indicate no linear association. Correlation describes association only and does not establish that one variable causes the other.

Definition

What correlation measures

A correlation coefficient summarises how two variables move together in a single number between −1 and +1. The sign tells you the direction; the magnitude tells you the strength.

A positive correlation means high scores on one variable tend to accompany high scores on the other. A negative correlation means high scores on one accompany low scores on the other. A coefficient near zero means there is no consistent linear pattern — which, as the fourth panel below shows, is not the same as no relationship.

strong positivemoderate negative no relationshipcurved r = 0.94r = −0.78 r = 0.03r = 0.02 The fourth panel has an obvious relationship and an r of almost zero. Always plot the data first.
Four datasets. The fourth has a clear, strong relationship and a correlation of almost zero, because the relationship is curved rather than linear.
Correlation is a summary, and summaries lose information

Pearson's r compresses an entire scatterplot into one number, and it can only see straight lines. A curved relationship, a cluster of outliers or two distinct subgroups can all produce a coefficient that badly misrepresents the data. This is why plotting is not optional. A scatterplot costs one line of code and settles in seconds what no summary statistic can tell you on its own.

Choosing

Pearson, Spearman or Kendall?

The choice is driven by your measurement level and the shape of the relationship, not by which one your software offers first.

CoefficientUse whenMeasuresSymbol
Pearson's rBoth variables continuous, relationship linear, roughly normalLinear associationr
Spearman's rhoOrdinal data, non-linear but monotonic, or outliers presentMonotonic associationrₛ or ρ
Kendall's tauSmall samples or many tied ranksConcordance of pairsτ

The practical decision

Both variables interval or ratio, scatter looks like a straight band — Pearson
Either variable is ordinal (Likert items, rankings, grades) — Spearman
Relationship is monotonic but curved (rises then plateaus) — Spearman
Clear outliers you cannot justify removing — Spearman, which is far less sensitive to them
n below about 20, or lots of tied values — Kendall's tau
Spearman is Pearson on ranks

Spearman's rho is simply Pearson's r computed on the ranked data rather than the raw values. That is why it handles outliers and curved-but-monotonic relationships: converting to ranks removes the influence of extreme values and of the exact spacing between them.

Not sure which coefficient your data need?

Send the variables and how they were measured. A named statistician confirms the right coefficient, runs it, and gives you the annotated output and the reporting sentence.

Get a fixed quote

Assumptions

Assumptions, and why you must plot first

Pearson's r carries assumptions that are routinely ignored, and the cost of ignoring them is a coefficient that means something other than what you think it means.

AssumptionHow to checkIf it fails
LinearityScatterplotUse Spearman, or transform the variable
Both variables continuousMeasurement levelUse Spearman for ordinal data
No influential outliersScatterplotUse Spearman, or report both with and without
HomoscedasticityScatterplot — even vertical spreadInterpret cautiously; consider transformation
Bivariate normalityHistograms, Q-Q plotsMatters mainly for the p-value and CI, not r itself

Every one of those checks except the last is answered by looking at a single scatterplot, which takes seconds. A single outlying point can move r from 0.10 to 0.60, or mask a genuine relationship entirely.

The restricted range trap

If you correlate university entry scores with degree performance using only admitted students, you have already removed the low end of the entry-score range. Restricting the range mechanically shrinks r — a genuine relationship in the full population can look like nothing in your sample. Always ask whether your sampling truncated one of the variables.

Worked example

Worked example: calculating Pearson's r by hand

Six participants complete a study skills measure (X) and sit an exam (Y). We want the correlation between them.

ParticipantXYX−X̄Y−Ȳ(X−X̄)(Y−Ȳ)(X−X̄)²(Y−Ȳ)²
11054−5−126025144
21258−3−824964
31462−1−44116
41670144116
518743824964
620785126025144
Sum903960017670448

Step 1 — the means

X̄ = 90 / 6 = 15 and Ȳ = 396 / 6 = 66

Step 2 — the deviations and their products

Each row subtracts the mean, then multiplies the two deviations together. Those products are what carry the relationship: when both deviations have the same sign, the product is positive, pushing r upwards.

Step 3 — apply the formula

r = Σ(X−X̄)(Y−Ȳ) / √[Σ(X−X̄)² × Σ(Y−Ȳ)²]

r = 176 / √(70 × 448) = 176 / √31360 = 176 / 177.09 = 0.994

Step 4 — test it

t = r × √[(n−2) / (1−r²)] = 0.994 × √(4 / 0.0120) = 0.994 × 18.26 = 18.15

With df = n − 2 = 4, that gives p < .001.

Why this example is unrealistic

An r of 0.994 essentially never occurs with real behavioural data — the numbers here were chosen so the arithmetic stays clean. Correlations in psychology and education are typically between 0.10 and 0.40. Treat any r above 0.90 in real data as a prompt to check whether you have accidentally correlated a variable with a version of itself.

Interpretation

Interpreting r and r squared

The coefficient itself is not on a scale most people read intuitively. Squaring it helps.

rVariance explainedConventional label
0.100.011%Small
0.300.099%Medium
0.500.2525%Large
0.700.4949%Very large
0.900.8181%Rare in behavioural data

is the proportion of variance in one variable that is shared with the other. An r of 0.30 — a “medium” effect by Cohen's conventions — accounts for 9% of the variance, leaving 91% unexplained. Stating both keeps the interpretation honest.

Cohen's labels are conventions, not laws

Cohen himself warned against applying them mechanically. In a field where correlations of 0.10 are the norm, an r of 0.25 may be substantial; in a calibration study, 0.90 may be unacceptably poor. Interpret against your field's typical effects, and always report the confidence interval around r.

Correlation with a binary variable

If one variable is genuinely dichotomous — passed or failed, treated or untreated — Pearson's r computed on 0/1 coding has a special name, the point-biserial correlation, but it is arithmetically identical and is interpreted the same way. It relates directly to the independent t-test: a significant point-biserial correlation and a significant t-test on the same data are the same result expressed twice. If the binary split is artificial, however — a continuous variable you cut at the median — expect the coefficient to shrink, because dichotomising throws away real information and typically costs you around 20% of your statistical power.

The confidence interval around r

A correlation from a small sample is very imprecise, and reporting r alone hides that. With n = 20, an observed r of 0.40 has a 95% interval of roughly [−0.05, 0.72] — consistent with no relationship at all and with a strong one. With n = 200 the same r gives roughly [0.28, 0.51], which is a genuinely informative result.

Get the interval as well as the coefficient

Our confidence interval calculator computes intervals for means and proportions, and the effect size calculator handles standardised effects with their intervals.

Use the calculator

Worked example

Worked example: Spearman's rho

Eight students rank their confidence with statistics (1 = least confident) and are separately ranked by exam performance. Both variables are ordinal, so Pearson is inappropriate.

StudentConfidence rankExam rankd
A12−11
B2111
C34−11
D4311
E56−11
F6511
G78−11
H8711
Sum8

rₛ = 1 − [6Σd² / (n(n²−1))] = 1 − [(6 × 8) / (8 × 63)] = 1 − (48 / 504) = 1 − 0.095 = 0.905

A rho of 0.905 indicates a strong monotonic relationship: students who rank themselves as more confident do tend to rank higher on the exam, with each pair differing by only one rank position.

When you have tied ranks

The simple formula above assumes no ties. With tied values — common in Likert data, where many respondents give the same answer — use the Pearson formula applied to the ranks instead. Every statistical package does this automatically, but the hand formula will be slightly wrong.

Extension

Partial correlation: holding a third variable constant

If you suspect a third variable is inflating or masking a relationship, a partial correlation estimates the association between X and Y with the influence of that third variable removed from both.

Worked example

Suppose study hours and exam score correlate at r = .55. You suspect prior attainment drives both. Prior attainment correlates .60 with study hours and .65 with exam score. The partial correlation is:

rₓₖ·ₛ = (rₓₖ − rₓₛrₖₛ) / √[(1 − rₓₛ²)(1 − rₖₛ²)]

= (.55 − (.60 × .65)) / √[(1 − .36)(1 − .4225)]

= (.55 − .39) / √(.64 × .5775) = .16 / .608 = .263

The association drops from .55 to .26 once prior attainment is held constant. Roughly half the original relationship was attributable to the fact that stronger students both study more and score higher — which is a substantively different story from the raw coefficient.

CoefficientValueInterpretation
Zero-order r.55The raw association, confounded
Partial r.26With prior attainment held constant
Difference−.29The portion explained by the confounder
Partial correlation is not a causal fix

Controlling for one measured confounder does not make the relationship causal. There may be others you did not measure, and statistical control cannot address them. Partial correlation tells you the association survives adjustment for the variables you have — nothing about the ones you have not.

Partial versus semi-partial

A partial correlation removes the third variable from both X and Y. A semi-partial (or part) correlation removes it from only one of them, and is what regression reports when it gives the unique contribution of a predictor. They answer different questions, and software labels them inconsistently, so check which one you are reading.

Inference

Why correlation is not causation

This is the single most repeated warning in statistics and still the most frequently violated in discussion sections. A correlation between X and Y is consistent with several very different explanations, and the coefficient cannot distinguish between them.

ice cream sales drowning deaths hot weather r = 0.81 — but neither causes the other A third variable drives both. This is confounding, and no correlation coefficient can detect it.
Ice cream sales and drowning deaths correlate strongly. Neither causes the other; hot weather drives both.
ExplanationExample
X causes YStudying more improves exam performance
Y causes XDoing well makes students more willing to study
A third variable causes bothConscientiousness drives both studying and performance
Selection effectOnly motivated students enrolled in the first place
ChanceWith enough variables tested, some will correlate by luck

Establishing causation requires design, not analysis: randomisation, temporal ordering, or a credible identification strategy. No correlation coefficient, however large and however significant, substitutes for it.

The wording examiners look for

Write “was associated with”, “predicted” (in the statistical sense), or “covaried with”. Avoid “led to”, “caused”, “improved” or “affected” unless your design supports a causal claim. This single habit protects a great many discussion sections.

Pitfalls

Seven mistakes that cost marks

1. Not plotting the data

A curved relationship, an outlier or two subgroups will all produce a misleading coefficient. The scatterplot takes seconds and catches all three.

2. Using Pearson on ordinal data

Likert items, rankings and grades are ordinal. The spacing between response options is not known to be equal, so Spearman is the defensible choice.

3. Claiming causation

A correlation establishes that two variables move together, nothing more. Rewrite any sentence that says one variable improved, raised, reduced or caused another unless your design supports it.

4. Running dozens of correlations and reporting the significant ones

A correlation matrix with 10 variables contains 45 coefficients; at &alpha; = .05 you expect around two to be significant by chance alone. Either correct for multiple comparisons or state clearly that the analysis was exploratory.

5. Interpreting r as a percentage

An r of 0.50 does not mean 50% of anything. It is = 0.25, or 25%, that has the variance interpretation.

6. Ignoring restricted range

If your sample truncates one variable, r will understate the population relationship. Say so.

7. Reporting r without n or a confidence interval

An r of 0.45 from six participants and from six hundred are entirely different findings. The reader needs n to tell them apart.

Reporting

Reporting correlation in APA style

APA 7 wants the coefficient italicised, degrees of freedom in parentheses, no leading zero before the decimal point, and an exact p-value.

SituationHow to write it
Pearson, significantr(48) = .42, p = .002, 95% CI [.16, .63]
Pearson, non-significantr(28) = .19, p = .314
Spearmanrₛ(38) = .61, p < .001
Very small pp < .001 — never p = .000
With variance explainedr(98) = .35, p < .001, r² = .12
df = n − 2 for Pearson and Spearman, not n
No leading zero.42, not 0.42, because r cannot exceed 1
Two decimal places for r, three for p
Report the confidence interval around r wherever the journal allows it
Use a correlation matrix when reporting more than about four coefficients
State which coefficient you used and why, in the analysis section
A sentence that earns marks

“Study skills scores were moderately positively associated with exam performance, r(98) = .35, p < .001, 95% CI [.16, .51], accounting for approximately 12% of the variance. As the design was cross-sectional, no causal inference is drawn.” That reports the coefficient, its precision, its practical size and its limits in three clauses.

Have your correlations and write-up checked

Send your results chapter. A named statistician verifies the coefficients, checks the assumptions were met, and flags any causal language an examiner would query.

See results chapter review

Answers

Frequently asked questions

What is the difference between Pearson and Spearman correlation?

Pearson's r measures linear association between two continuous variables and assumes the relationship is a straight line. Spearman's rho measures monotonic association by correlating the ranks instead of the raw values, so it handles ordinal data, curved-but-consistent relationships and outliers. If either variable is ordinal — such as a Likert item — Spearman is the defensible choice.

What counts as a strong correlation?

By Cohen's conventions, .10 is small, .30 medium and .50 large, but these are field-dependent conventions rather than rules. In psychology and education, correlations above .50 are uncommon. Interpret against typical effects in your own literature, and always report the confidence interval, because a coefficient from a small sample is very imprecise.

Does correlation prove causation?

No. A correlation is equally consistent with X causing Y, Y causing X, a third variable causing both, a selection effect, or chance. Establishing causation requires design features such as randomisation and temporal ordering, not a larger coefficient. Use wording such as “was associated with” rather than “caused”.

What does r squared tell me?

It is the proportion of variance shared between the two variables. An r of .30 gives r² = .09, meaning the variables share 9% of their variance and 91% is unexplained. Reporting r² alongside r keeps the interpretation grounded, because r on its own tends to sound more impressive than it is.

Can a correlation be zero when the variables are clearly related?

Yes. Pearson's r only detects linear relationships. A strong curved relationship — performance rising with arousal and then falling, for instance — can produce an r near zero. This is the main reason to plot your data before computing any coefficient.

What sample size do I need for a correlation?

It depends on the effect you want to detect. To detect r = .30 with 80% power at α = .05 you need about 85 participants; to detect r = .50, about 29. Small samples produce very wide confidence intervals, which is why correlations from fewer than about 30 participants should be treated as provisional.

How do I report a correlation in APA style?

Give the coefficient italicised with degrees of freedom in parentheses, no leading zero, and an exact p-value: r(48) = .42, p = .002. Degrees of freedom are n − 2. Add the 95% confidence interval where the journal allows, and state which coefficient you used in the analysis section.

Send the data. Get a fixed quote.

Attach your dataset or just describe the project. A named statistician replies with a price and a deadline, usually within one working day.