Correlation Coefficient Calculator
Calculate the Pearson correlation coefficient (r) to measure linear relationship between two variables.
Quick Examples
Pearson Correlation Coefficient
Interpreting r Values
- r = 1: Perfect positive correlation
- r = −1: Perfect negative correlation
- r = 0: No linear correlation
- |r| > 0.7: Strong correlation
- 0.3 < |r| < 0.7: Moderate correlation
- |r| < 0.3: Weak correlation
What Is Correlation?
Correlation measures how strongly two variables move together. The Pearson correlation coefficient, written r, summarizes an entire scatterplot in a single number between −1 and 1. A value near 1 means the two variables rise together; a value near −1 means one rises as the other falls; a value near 0 means there is no straight-line relationship at all.
Scientists, economists, and analysts use correlation as a first check before building models: does advertising spending move with revenue, does study time move with exam scores, does temperature move with ice-cream sales? The calculator on this page computes r from paired data points, so you can quantify the relationship instead of guessing from a chart. Remember the golden rule, though: correlation describes association, not causation.
Understanding the Pearson Formula
The formula looks intimidating, but each part has a plain meaning. For every data point, subtract the mean of x and the mean of y to get each point's deviation from average. Multiply the two deviations: the product is positive when a point is above average on both variables or below average on both — the signature of co-movement. Adding those products gives the numerator, which is large when most points move together and cancels out when they do not. The denominator simply rescales everything so the final result always lands between −1 and 1, no matter the units of the data.
Step-by-Step Calculation
- Step 1: List the paired data. Here x = [1, 2, 3, 4, 5] and y = [2, 4, 5, 4, 5].
- Step 2: Find the means: x̄ = 3 and ȳ = 4.
- Step 3: For each pair, multiply the deviations: (−2)(−2) = 4, (−1)(0) = 0, (0)(1) = 0, (1)(0) = 0, (2)(1) = 2. Their sum is 6.
- Step 4: Sum the squared deviations: Σ(xᵢ − x̄)² = 10 and Σ(yᵢ − ȳ)² = 6.
- Step 5: Divide: r = 6 / √(10 × 6) = 6 / √60 = 0.7746 — a strong positive correlation.
Worked Examples
Example 1: Strong positive correlation
For x = [1, 2, 3, 4, 5] and y = [2, 4, 5, 4, 5], the step-by-step calculation above gives r = 0.7746. Values above 0.7 count as strong, so these variables clearly rise together.
Example 2: Perfect negative correlation
For x = [1, 2, 3] and y = [6, 4, 2], every increase in x is matched by an equal decrease in y. The formula returns exactly r = −1.0, the strongest possible negative relationship.
Common Mistakes
- Reading causation into correlation: ice-cream sales and drowning deaths correlate because both rise in summer, not because one causes the other.
- Ignoring outliers: a single extreme point can drag r far from the true relationship.
- Using r on curved relationships: a perfect U-shaped pattern can score r ≈ 0 even though the variables are strongly related.
- Trusting r from tiny samples: with only three or four points, the coefficient swings wildly.
Frequently Asked Questions
What does r = 0 actually mean?
It means there is no linear relationship. The variables might still be related in a curved or more complex way — r only detects straight-line patterns.
How many data points do I need?
There is no hard minimum, but results stabilize as the sample grows. Treat r from fewer than ten pairs as a rough hint, not a conclusion.
Can correlation be greater than 1?
Never. The denominator of the Pearson formula normalizes the result, so r is mathematically trapped between −1 and 1.
Should I use Pearson or Spearman correlation?
Pearson measures linear relationships between actual values. If your data is ranked, skewed, or curved but monotonic, Spearman's rank correlation is the safer choice.
The Coefficient of Determination: r²
Squaring r gives r², the coefficient of determination — the fraction of the variation in one variable that is associated with variation in the other. An r of 0.8 becomes r² = 0.64: about 64% of the variation is shared, leaving 36% unexplained by the straight-line relationship. This is why researchers often quote r² rather than r — it reads as a percentage of "explained" variation.
Covariance: The Unscaled Version
The numerator of the Pearson formula, divided by the count, is the covariance — the raw co-movement before rescaling. Pearson's r is simply the covariance divided by the two standard deviations:
Covariance carries awkward units (the product of the two variables' units), which is why r — unit-free and bounded — is reported instead.
Pearson vs Spearman: Which Correlation?
| Pearson r | Spearman ρ | |
|---|---|---|
| Measures | Linear relationship | Monotonic relationship (ranks) |
| Uses | Actual values | Rank order |
| Outliers | Sensitive | Resistant |
| Curved trends | Misses them | Detects them if monotonic |
| Best for | Linear, roughly normal data | Skewed, ranked, or ordinal data |
If Pearson and Spearman disagree sharply on the same data, suspect an outlier or a curved relationship — the gap itself is diagnostic.
Is My Correlation Significant?
A large r from a handful of points can be luck. The standard check is a t-test: t = r√[(n−2)/(1−r²)]. With r ≈ 0.77 and n = 5 (the worked example above), t ≈ 2.12 with 3 degrees of freedom — suggestive, but with so few points the evidence is thin. The same r = 0.77 with n = 50 would be overwhelmingly significant. Always report r together with n.
Where Correlation Is Used
- Medicine: linking dosage levels to patient outcomes before running a trial.
- Finance: measuring how two assets move together — the basis of diversification.
- Marketing: checking whether ad spend actually moves with revenue.
- Psychology: study time vs exam scores, sleep vs memory — the classic textbook pairs.
Correlation in Spreadsheets
In Excel or Google Sheets, =CORREL(array1, array2) returns Pearson's r for two equal-length ranges — the fastest way to check a relationship before building anything fancier. Excel's Data Analysis Toolpak adds a full correlation matrix for three or more variables at once.
Spurious Correlations
Two series that both trend over time will correlate strongly even with no connection between them — the classic "ice-cream sales vs drowning deaths" both rise in summer. Always plot the data before trusting r, and ask what third variable might be driving both.