Statistics & Probability Correlation, Regression & Association Pearson product-moment correlation

Pearson Correlation Coefficient (r) Calculator

Pearson's r measures how tightly two variables track a straight line together, on a scale from −1 to +1. Paste your paired values and this calculator returns r, r-squared, the t test of whether r differs from zero, an exact two-tailed p-value, and a Fisher z confidence interval for the true correlation. The deviation-products table underneath shows exactly which pairs pushed r up and which pulled it down.

Calculator

This calculator runs in your browser. Enable JavaScript for live results — the inputs, formula and worked example below remain fully readable without it.

Inputs this calculator takes, with typical values
InputWhat to enterExample
x valuesThe first variable, separated by commas, spaces or line breaks.1, 2, 3, 4, 5
y valuesThe second variable, in the same order. Pairs are matched by position.2, 4, 5, 4, 5
Confidence level for the intervalSets the width of the Fisher z interval for the population correlation.95%

It returns

  • Pearson r — Between −1 and +1. Zero means no linear association.
  • r² (coefficient of determination)
  • Conventional description
  • t statistic
  • Two-tailed p-value
  • Lower limit for ρ
  • Upper limit for ρ
  • Pairs used

The formula

r=(xx¯)(yy¯)(xx¯)2(yy¯)2
t=rn21r2
z=12ln1+r1r

In plain text: r = Σ(x−x̄)(y−ȳ) / √[Σ(x−x̄)² · Σ(y−ȳ)²]

  • rPearson correlation coefficient (−1 to +1)
  • x̄, ȳMeans of the two variables
  • nNumber of paired observations (count)
  • ρThe population correlation that r estimates

r is the covariance divided by the product of the two standard deviations, which is what confines it to the interval from −1 to +1.

Updated Category Correlation, Regression & Association Verified against published test cases Reading time 10 min

What r measures

Pearson's r answers one question: how close do the points come to lying on a single straight line, and does that line rise or fall? A value of +1 means every point sits exactly on an upward-sloping line, −1 means exactly on a downward-sloping one, and 0 means no linear pattern at all.

The construction is simple. For each pair, measure how far x sits from its mean and how far y sits from its mean, and multiply the two deviations. Pairs where both variables are above their means, or both below, contribute a positive product. Pairs where one is above and the other below contribute a negative one. Add the products and you have the covariance, which already answers the question — except that its size depends on the units. A covariance of 400 could indicate a tight relationship in millimetres or a weak one in kilometres.

Dividing by the product of the two standard deviations strips the units out. That is all r is: a covariance divided by the two spreads, which mathematically confines it to the range −1 to +1 by the Cauchy-Schwarz inequality. The consequence worth remembering is that r is invariant to any change of scale or origin: measure temperature in Fahrenheit or Celsius, prices in dollars or euros, and r does not move.

What r does not measure is the steepness of the relationship. A slope of 0.01 and a slope of 100 can both give r = 0.99 if the points hug the line equally tightly. For steepness you need linear regression; r is about tightness, not about rate of change.

Testing r, and putting an interval around it

An r computed from a handful of points can be large by luck. With five random pairs the sample correlation exceeds 0.878 in magnitude 5% of the time even when the two variables are completely unrelated. So a correlation needs a significance test, and the test statistic is t = r√(n−2) / √(1−r²) with n − 2 degrees of freedom.

That formula is exactly the t test for the slope in simple regression, and it must be, since the slope is zero precisely when r is zero. The n − 2 comes from the two parameters implicitly estimated — the two means. As n grows, the correlation needed to reach significance falls sharply: 0.878 at n = 5, 0.632 at n = 10, 0.197 at n = 100. With 1,000 pairs an r of 0.07 is significant and explains half a percent of the variance, which is the clearest demonstration that significance and importance are different questions.

For an interval around r you cannot use r ± something, because the sampling distribution of r is skewed and bounded — an r of 0.9 cannot stray far above itself but can fall a long way. Fisher's transformation fixes this: z = ½·ln[(1+r)/(1−r)] maps the bounded scale onto the whole real line, where the sampling distribution is approximately normal with standard error 1/√(n−3). Build the interval on the z scale, then transform both limits back with the hyperbolic tangent. The result is asymmetric around r, which is correct: the interval reported for the calculator's default data runs from −0.34 to +0.98, with far more room above the point estimate than below it.

Worked example: five pairs by hand

Take the default data, x = 1, 2, 3, 4, 5 and y = 2, 4, 5, 4, 5.

  1. Means. x̄ = 15/5 = 3; ȳ = 20/5 = 4.
  2. Deviations. x − x̄: −2, −1, 0, 1, 2. y − ȳ: −2, 0, 1, 0, 1.
  3. Products. 4, 0, 0, 0, 2, so Sₓᵧ = 6. Only two pairs contributed anything; the middle three sat on a mean.
  4. Sums of squares. Sₓₓ = 4+1+0+1+4 = 10; Sᵧᵧ = 4+0+1+0+1 = 6.
  5. r. 6 / √(10 × 6) = 6 / √60 = 6 / 7.745967 = 0.774597.
  6. r². 0.774597² = 0.600. Sixty percent of the variation in y is associated with variation in x.
  7. t statistic. 0.774597 × √3 / √(1 − 0.6) = 1.341641 / 0.632456 = 2.1213, on 3 degrees of freedom.
  8. Significance. The two-tailed 5% cut-off for t on 3 df is 3.182, and 2.12 falls well short. Equivalently, the critical r at n = 5 is 0.878 and 0.775 does not reach it. Not significant.
  9. Fisher interval. z = ½·ln(1.774597/0.225403) = ½ × 2.063438 = 1.031719. SE = 1/√2 = 0.707107. The 95% multiplier is 1.959964, so the interval on the z scale is 1.031719 ± 1.385903, and transforming back gives −0.340 to +0.984.

The interval is the honest summary. An r of 0.77 sounds impressive, but with five points the data are compatible with everything from a moderate negative relationship to a nearly perfect positive one. Reporting “r = 0.77” alone would be indefensible; reporting “r = 0.77, 95% CI −0.34 to 0.98, n = 5” tells the truth.

How to read the coefficient

Square it first. r² is the share of variation in one variable that is associated with the other, and it falls away much faster than r suggests: r = 0.5 gives r² = 0.25, so a “moderate” correlation accounts for a quarter of the variation and leaves three quarters unexplained. r = 0.3 accounts for 9%.

Treat the verbal labels as conventions, not facts. Calling |r| below 0.2 “very weak” and above 0.8 “very strong” is a widely used convention and nothing more; an r of 0.4 between a biomarker and a clinical outcome may be a major finding, while an r of 0.9 between two supposedly independent sensor channels is a fault report. Compare against the norms of your own field.

Check the significance test and the interval together. A significant r on 2,000 pairs may be trivially small; a non-significant r on 8 pairs may be consistent with a very strong relationship. The p-value tells you whether zero is ruled out; the interval tells you what is not ruled out.

Look at the deviation-products table for single dominant pairs. Pearson's r is not robust: one outlying point far from both means can create a large correlation from noise or destroy a real one. If one row's product dwarfs the rest, re-run without it, and consider Spearman's rank correlation, which uses ranks and is far less sensitive to extreme values.

Finally, the standing caution: correlation is not causation, and it is not even evidence of a relationship in a specific direction. Two variables can correlate because one drives the other, because a third drives both, or because of how the sample was selected. Restricting the range of x — studying only high earners, only large firms, only accepted applicants — systematically shrinks r towards zero even when the underlying relationship is strong.

How large must r be to reach significance?

Critical values of |r| for a two-tailed test at α = 0.05, computed from the t cut-off as r = t / √(t² + n − 2). An observed |r| above the tabulated value rejects ρ = 0.
n (pairs)df = n − 2Critical tCritical |r|r² at that point
533.1820.8780.771
1082.3060.6320.399
20182.1010.4440.197
30282.0480.3610.130
50482.0110.2790.078
100981.9840.1970.039

Read the last column carefully: at n = 100 a barely significant correlation explains under 4% of the variation. Significance is a statement about zero, not about size.

Where r misleads

  • Curved relationships. A perfect parabola symmetric about the mean of x has r = 0. Always look at the plot before concluding there is no relationship.
  • Outliers. A single distant point can drag r from 0.1 to 0.8 or the reverse. Check the deviation-products table for a row that dominates the sum.
  • Restricted range. Correlating test scores with performance among people who were selected on the test guarantees an attenuated r. The population value is larger than the sample suggests.
  • Aggregated data. Correlations computed on group averages are typically far higher than the same correlation on individuals — the ecological fallacy.
  • Mixed subgroups. Two subgroups with no internal correlation can produce a strong overall r simply because their centres differ. Simpson's paradox is the extreme form, where the overall sign reverses within every subgroup.
  • Reading causation into it. r is symmetric: it cannot distinguish x causing y from y causing x, let alone from a common cause.

Related measures

If you want to predict one variable from the other, or need the relationship in real units, move to the linear regression calculator. In simple regression R² equals r², and the t test for the slope is identical to the t test reported here — the two pages answer different questions about the same fit.

For the unstandardised version, in the original units of both variables, use the covariance calculator. For monotonic relationships that are not straight, or for data with outliers or ordinal scales, use Spearman's rank correlation, which applies this same formula to ranks rather than raw values.

For binary outcomes, correlation is the wrong summary and an odds ratio or a chi-square test of association is appropriate. And with several predictors, the individual correlations stop telling the whole story, because predictors correlated with each other share explanatory power; the adjusted R² calculator deals with that setting.

The coefficient was formalised by Karl Pearson in 1896, building on Francis Galton's work on regression towards the mean in the 1880s; Fisher's z transformation followed in 1915 and is still the standard way to build an interval for a correlation.

Frequently asked questions

What counts as a strong correlation?

By the common convention, |r| under 0.2 is very weak, 0.2 to 0.4 weak, 0.4 to 0.6 moderate, 0.6 to 0.8 strong and above 0.8 very strong. These are labels, not thresholds with any theoretical basis. In physics an r of 0.95 may indicate a problem; in psychology an r of 0.3 can be a headline result. Square the value and ask whether explaining that share of the variation is useful for your purpose.

Can r be significant but useless?

Yes, routinely. With 1,000 pairs, an r of 0.07 is significant at the 5% level and explains 0.07² = 0.49% of the variation. Significance tests whether the population correlation differs from exactly zero, which is a very low bar in a large sample. Report r, r², the sample size and the confidence interval together, and let the reader judge the size.

What does r = 0 mean?

That there is no linear association — not that the variables are unrelated. A perfect symmetric parabola gives r = 0, as does any relationship where the deviation products cancel. It also does not imply independence except in the special case of jointly normal variables. Plot the data before drawing any conclusion from an r near zero.

How is r related to R² in regression?

In simple regression with one predictor, R² is exactly r². The correlation keeps the sign and tells you the direction; R² discards it and reports the share of variance explained. Both are computed from the same three sums of squares. With more than one predictor the two part company, and only R² generalises.

Why does the confidence interval not sit symmetrically around r?

Because r is bounded at ±1, so its sampling distribution is skewed whenever the true correlation is away from zero. Fisher's transformation maps r onto an unbounded scale where the distribution is roughly normal, the interval is built symmetrically there, and both limits are transformed back. The result is asymmetric in the original units — correctly so, since there is more room below a large positive r than above it.

How many pairs do I need?

Three at an absolute minimum, but useful precision needs far more. To be reasonably confident of detecting a true correlation of 0.3 at 80% power and α = 0.05 you need about 85 pairs; for 0.5 about 29. Fisher's interval also relies on a normal approximation that is only rough below about ten pairs, which is why intervals from small samples come out so wide.

Should I use Pearson or Spearman?

Use Pearson when the relationship is plausibly straight, both variables are interval-scaled and there are no severe outliers. Use Spearman when the relationship is monotonic but curved, when either variable is ordinal, or when outliers are distorting the picture. Spearman is simply Pearson's formula applied to the ranks, so it measures monotonic rather than linear association.

Does a correlation prove one variable causes the other?

No. r is symmetric in x and y, so it cannot even indicate a direction, and a third variable driving both produces exactly the same coefficient as a direct effect. Selection into the sample can also manufacture a correlation that does not exist in the population. Causal claims come from the study design — randomisation, temporal ordering, control of confounders — never from the coefficient.

References

  • NIST/SEMATECH e-Handbook of Statistical Methods, Section 1.3.5.13 (Correlation)National Institute of Standards and Technology
  • R. A. Fisher, “Frequency distribution of the values of the correlation coefficient in samples from an indefinitely large population”, Biometrika 10(4), 1915 — Biometrika Trust
  • Statistical Power Analysis for the Behavioral Sciences, 2nd ed. — Jacob Cohen, Lawrence Erlbaum Associates