Correlation Coefficient: How to Calculate and Interpret r
Do taller people tend to weigh more? Do students who study longer score higher? The correlation coefficient, usually written r, puts a number on how closely two measurements move together. It runs from −1 to +1, so one figure tells you both the direction and the strength of the link.
This guide calculates r by hand on a small data set, explains what r and r² say, and lists the traps that make a correlation look more (or less) meaningful than it is.
What r measures
- r = +1: every point lies exactly on an upward-sloping straight line.
- r = −1: every point lies exactly on a downward-sloping straight line.
- r = 0: no straight-line relationship at all.
The key word is linear. Pearson's r only captures straight-line patterns, and it is unaffected by the units used: converting centimetres to inches, or dollars to euros, does not change it.
r = Σ(x − mean x)(y − mean y) ÷ √[ Σ(x − mean x)² × Σ(y − mean y)² ]The top is the sum of cross-products of deviations; the bottom rescales it to the range −1 to +1.
Worked example with five points
Suppose five students record hours studied (x) and quiz marks out of 5 (y). The x values are 1, 2, 3, 4, 5, with a mean of 3. The y values are 2, 4, 5, 4, 5, with a mean of 4.
| x | y | x − 3 | y − 4 | Product | (x − 3)² | (y − 4)² |
|---|---|---|---|---|---|---|
| 1 | 2 | −2 | −2 | 4 | 4 | 4 |
| 2 | 4 | −1 | 0 | 0 | 1 | 0 |
| 3 | 5 | 0 | 1 | 0 | 0 | 1 |
| 4 | 4 | 1 | 0 | 0 | 1 | 0 |
| 5 | 5 | 2 | 1 | 2 | 4 | 1 |
| Total | 6 | 10 | 6 |
Then r = 6 ÷ √(10 × 6) = 6 ÷ √60 = 6 ÷ 7.746 = 0.775. The points rise together, with a fairly strong upward trend. The correlation coefficient calculator gives the same result from the raw lists.
The numerator, 6, divided by n − 1 = 4 gives the sample covariance of 1.5. Dividing that by the two standard deviations (√2.5 and √1.5) is what turns the covariance into r. The covariance calculator shows that intermediate step.
Direction, strength and rescaling
The sign of r shows direction and its size shows strength. If the same five students had marks of 5, 4, 3, 2, 1 as hours studied went up from 1 to 5, the points would fall exactly on a downward line and r would be −1. A negative r is not worse than a positive one; it just means one variable tends to fall as the other rises.
Rescaling does not change r. Multiplying every mark by 10, or adding 100 to every value of x, leaves r at 0.775, because the formula works with deviations from the mean and divides out the spread.
What r² adds
Squaring r gives the coefficient of determination. Here r² = 0.775² = 0.60, meaning about 60% of the variation in the marks is accounted for by a straight-line relationship with hours studied. The remaining 40% is down to other factors or noise.
r² is easier to interpret than r because it is a share of the whole. It also shows why moderate correlations explain less than they sound: r = 0.5 corresponds to r² = 0.25, so only a quarter of the variation.
Traps that make r misleading
- Correlation is not causation. Two variables can move together because one causes the other, because a third factor drives both, or by coincidence.
- Curved relationships. The values x = −2, −1, 0, 1, 2 and y = 4, 1, 0, 1, 4 follow a perfect U-shape, yet r is exactly 0.
- Outliers. A single extreme point can create or destroy a strong r.
- Different shapes, same r. The well-known Anscombe's quartet is four small data sets with almost the same r (about 0.82) but very different scatterplots. Always plot the data.
- Small samples. With only five points, an r of 0.775 is not strong evidence of a real relationship: the usual significance test gives a p-value of about 0.12.
- Restricted range. If you only look at a narrow slice of one variable, the correlation usually appears weaker than it is overall.
When ranks are better than raw values
If the relationship is consistently increasing but curved, or if the data is ranked, a rank-based measure such as Spearman's correlation is a better fit. It works by applying the same formula to the ranks of the values instead of the values themselves, so it is less sensitive to outliers and does not require a straight line.
Labels such as weak, moderate and strong are conventions, not rules. Cohen's well-known benchmarks of 0.1, 0.3 and 0.5 are used in some behavioural sciences, but what counts as a strong correlation depends heavily on the field.
- Correlation Coefficient Calculator: Paste paired X and Y values, choose Pearson, Spearman or Kendall, and get the coefficient together with its Z score, one-sided p-value, confidence intervals and the least-squares line.
- Covariance Calculator: Paste your X and Y values, one pair per row, and the calculator returns the sample covariance, the population covariance and the mean of each variable. Add a third column of weights to get the weighted version.
This article is general information, not professional advice. See our Disclaimer and Editorial Policy.
More articles
How to Add and Subtract Fractions With Different Denominators
You cannot add 1/2 and 1/3 by adding the tops and bottoms. This guide shows the common-denominator method, with worked examples and mixed numbers.
Common Probability Mistakes and How to Avoid Them
Probability is full of results that feel wrong. Here are five classic mistakes, each with a short calculation showing the correct answer.
Converting Between Fractions, Decimals and Percentages
Fractions, decimals and percentages are three ways of writing the same quantity. Learn the six conversions, repeating decimals and the equivalents worth memorising.