How to Calculate the Correlation Coefficient
The Pearson correlation coefficient (r) measures the strength and direction of the linear relationship between two variables. It ranges from −1 to +1, where +1 is a perfect positive correlation, −1 is a perfect negative correlation, and 0 means no linear relationship.
The Formula
r = Σ[(xᵢ − x̄)(yᵢ − ȳ)] / √[Σ(xᵢ − x̄)² × Σ(yᵢ − ȳ)²]
Step-by-Step Example
Data: x = 5, y = 5
Step 1: Calculate means. x̄ = 3, ȳ = 4
Step 2: Calculate deviations.
| xᵢ | yᵢ | (xᵢ−x̄) | (yᵢ−ȳ) | Product | (xᵢ−x̄)² | (yᵢ−ȳ)² |
|---|---|---|---|---|---|---|
| 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 |
Step 3: Sum the columns. Σ products = 6, Σ(xᵢ−x̄)² = 10, Σ(yᵢ−ȳ)² = 6
Step 4: Apply the formula. r = 6 / √(10 × 6) = 6 / √60 = 6 / 7.746 = 0.775
Interpreting r Values
| r Value | Interpretation |
|---|---|
| 0.9 to 1.0 | Very strong positive |
| 0.7 to 0.9 | Strong positive |
| 0.5 to 0.7 | Moderate positive |
| 0 to 0.5 | Weak positive |
| 0 | No linear relationship |
| Negative values | Same scale, opposite direction |
Important Caveat
Correlation does not imply causation. A high r value means two variables move together, but doesn't tell you why or which causes which.
Use our correlation coefficient calculator to analyze any dataset.