Correlation Coefficient Calculator Formula
Understand the math behind the correlation coefficient calculator. Each variable explained with a worked example.
Formulas Used
Pearson r
r = numerator / denomR-squared
r_squared = pow(numerator / denom, 2)Numerator
num_val = numeratorDenominator
den_val = denomVariables
| Variable | Description | Default |
|---|---|---|
n | Number of Pairs (n) | 5 |
sum_xy | Sum of (x*y) | 2350 |
sum_x | Sum of x | 75 |
sum_y | Sum of y | 150 |
sum_x2 | Sum of x-squared | 1175 |
sum_y2 | Sum of y-squared | 4650 |
numerator | Derived value= n * sum_xy - sum_x * sum_y | calculated |
denom | Derived value= sqrt((n * sum_x2 - pow(sum_x, 2)) * (n * sum_y2 - pow(sum_y, 2))) | calculated |
How It Works
How to Calculate the Pearson Correlation Coefficient
Formula
r = [n*Sum(xy) - Sum(x)*Sum(y)] / sqrt{[n*Sum(x^2) - (Sum(x))^2] * [n*Sum(y^2) - (Sum(y))^2]}
The Pearson correlation coefficient measures the strength and direction of the linear relationship between two variables. It ranges from -1 (perfect negative) to +1 (perfect positive). Zero indicates no linear relationship. R-squared gives the proportion of variance explained.
Worked Example
5 data pairs with given sums: Sum(xy)=2350, Sum(x)=75, Sum(y)=150, Sum(x^2)=1175, Sum(y^2)=4650.
- 01Numerator = 5*2350 - 75*150 = 11750 - 11250 = 500
- 02Denom part 1 = 5*1175 - 75^2 = 5875 - 5625 = 250
- 03Denom part 2 = 5*4650 - 150^2 = 23250 - 22500 = 750
- 04Denominator = sqrt(250 * 750) = sqrt(187500) = 433.01
- 05r = 500 / 433.01 = 1.1547... (check your sums!)
Frequently Asked Questions
What does r = 0 mean?
It means there is no linear relationship between the variables. However, a non-linear relationship could still exist. Always visualize the data with a scatter plot.
How do I interpret the magnitude of r?
Common benchmarks: |r| < 0.3 = weak, 0.3-0.7 = moderate, > 0.7 = strong. These are guidelines; context determines what counts as a meaningful correlation.
Does correlation imply causation?
No. Correlation measures association, not causation. Two variables may be correlated because of a confounding third variable, reverse causation, or coincidence.
Learn More
Guide
Regression Analysis Guide
Comprehensive guide to regression analysis. Learn how linear regression works, how to interpret slope and intercept, R-squared, residuals, and when to use regression.
Ready to run the numbers?
Open Correlation Coefficient Calculator