Correlation Calculator
Calculate the Pearson correlation coefficient (r) between two data sets
Frequently Asked Questions
Pearson correlation formula
r = Σ (x − x̄)(y − ȳ) ÷ √[Σ (x − x̄)² × Σ (y − ȳ)²]
r measures the strength and direction of a linear relationship, from −1 (perfect negative) through 0 (no linear relationship) to +1 (perfect positive). The calculator also gives the least-squares line y = slope × x + intercept, where slope = Σ (x − x̄)(y − ȳ) ÷ Σ (x − x̄)².
Example
X = 1, 2, 3, 4, 5 and Y = 2, 4, 5, 4, 5. The means are 3 and 4, the sum of cross-products is 6, and the sums of squares are 10 for X and 6 for Y. r = 6 ÷ √60 = 0.775, a strong positive correlation. r² = 0.60, so the line y = 0.6x + 2.2 explains 60% of the variation in Y.
Interpreting r
| |r| | Strength |
|---|---|
| 0.7 to 1.0 | Strong |
| 0.3 to 0.7 | Moderate |
| 0 to 0.3 | Weak |
These cutoffs are conventions; in some fields an r of 0.3 is considered meaningful, in physics 0.9 might be disappointing.
Is the correlation significant?
With few data points, a large r can still be chance. Test it with t = r × √(n − 2) ÷ √(1 − r²), with n − 2 degrees of freedom. In the example, t = 0.775 × √3 ÷ √0.4 = 2.12 with 3 degrees of freedom, a two-tailed p-value of about 0.12, so five points are not enough to rule out chance at the 5% level. With 30 data points, an r of 0.36 or more would be significant.
Common pitfalls
- Correlation is not causation. Ice cream sales and drownings are correlated because both rise in summer.
- Outliers can create or hide a correlation; always look at a scatter plot.
- Non-linear relationships: a perfect U-shape can have r near 0. Spearman's rank correlation handles monotonic curves and ranked data.
- Restricted range: looking only at high-scoring students hides the correlation that exists across all students.
For averages, use the average calculator; for planning how much data you need, the sample size calculator; and to compare two rates, the A/B test significance calculator.