Correlation Coefficient Calculator
Find Pearson r, R-squared, the regression line, and p-value for any two-variable dataset.
📊 What is the Correlation Coefficient Calculator?
The Pearson correlation coefficient (r) is a number between -1 and +1 that measures how strongly two continuous variables move together in a linear pattern. A value of +1 means a perfect positive linear relationship (when X increases, Y increases by a proportional amount). A value of -1 means a perfect negative linear relationship (when X increases, Y decreases proportionally). A value of 0 means no linear relationship exists between the two variables.
Correlation analysis is used in virtually every quantitative field. Medical researchers use it to study the relationship between a risk factor (e.g. blood pressure) and an outcome (e.g. incidence of stroke). Economists study the correlation between GDP growth and unemployment rates (Okun's Law). Engineers correlate operating temperature with equipment failure rates. Market analysts look at the correlation between two asset prices to assess diversification benefits. Education researchers measure the correlation between study hours and exam performance. In each case, the goal is to quantify how reliably one variable predicts the other.
This calculator computes Pearson r along with four additional outputs that together give a complete picture of the linear relationship. R-squared (r2) shows the proportion of variance in Y explained by X. The least-squares regression line y = mx + b gives the best linear prediction of Y from X and can be used to make forecasts. The t-statistic and two-tailed p-value test whether the observed correlation is statistically significant or could have occurred by chance. All five outputs are computed automatically from raw data pairs.
The Summary Statistics mode is useful when you already have pre-computed sums from a textbook problem or research paper. Instead of re-entering raw data, you enter n, Σx, Σy, Σx², Σy², and Σxy to compute r, the regression line, and the significance test directly. This matches the hand-calculation procedure taught in introductory statistics courses and lets you verify published results or complete homework problems efficiently.
📐 Formula
📖 How to Use This Calculator
Steps
💡 Example Calculations
Example 1 - Very Strong Positive Correlation (Income vs Spending)
Weekly income ($000s): 2, 4, 6, 8, 10, 12, 14, 16, 18, 20 and spending ($000s): 3, 7, 8, 14, 15, 19, 21, 25, 27, 30
Example 2 - Strong Negative Correlation (Temperature vs Heating Oil)
Temperature (C): 5, 8, 12, 15, 20, 22, 25, 28, 30, 35 and heating oil used (liters): 90, 85, 75, 68, 55, 50, 38, 30, 22, 10
Example 3 - Summary Statistics Mode (Exercise vs GPA)
A study of 25 students gave: n=25, SumX=87.5, SumY=82.5, SumX2=340, SumY2=295, SumXY=312
Example 4 - Weak Correlation (Age vs Job Satisfaction)
Ages: 30, 42, 55, 28, 65, 38, 51, 74, 45, 60 and job satisfaction (0-100): 72, 85, 78, 90, 82, 68, 75, 80, 71, 88
❓ Frequently Asked Questions
🔗 Related Calculators
What is the Pearson correlation coefficient and what does it measure?
The Pearson correlation coefficient (r) measures the strength and direction of the linear relationship between two continuous variables. It ranges from -1 to +1. r = 1 means a perfect positive linear relationship (as X increases, Y increases proportionally). r = -1 means a perfect negative linear relationship. r = 0 means no linear relationship. Values between 0.7 and 1.0 (or -0.7 and -1.0) indicate strong linear associations commonly reported in scientific literature.
What is the formula for Pearson r?
The computational formula is r = (n*SumXY - SumX*SumY) / sqrt((n*SumX2 - (SumX)2) * (n*SumY2 - (SumY)2)). The equivalent conceptual formula is r = Sum((xi - x_mean)(yi - y_mean)) / ((n-1)*sx*sy), where sx and sy are the sample standard deviations. Both formulas give the same result. This calculator uses the computational formula, which is numerically stable and works directly from the data.
How do I interpret the Pearson r value?
Common interpretation guidelines: |r| >= 0.9 = very strong, |r| >= 0.7 = strong, |r| >= 0.5 = moderate, |r| >= 0.3 = weak, |r| < 0.3 = negligible. The sign indicates direction: positive means both variables move together; negative means they move in opposite directions. These thresholds are general guidelines and vary by field. In physics, r > 0.99 may be expected; in social sciences, r = 0.5 is often considered strong.
What is R-squared and how does it differ from r?
R-squared (R2 = r2) is the coefficient of determination. It measures the proportion of variance in Y explained by the linear relationship with X. For example, r = 0.80 gives R2 = 0.64, meaning 64% of Y's variability is explained by X. r is dimensionless and ranges from -1 to +1, while R2 ranges from 0 to 1. R2 is always non-negative and does not tell you the direction of the relationship, while r does.
What does the p-value mean in a correlation test?
The p-value tests the null hypothesis that the true population correlation rho = 0 (no linear relationship). A small p-value (e.g. p < 0.05) means the observed r is unlikely if the true correlation were zero, so you reject the null and conclude a significant linear association exists. The test statistic is t = r * sqrt(n-2) / sqrt(1-r2), which follows a t-distribution with n-2 degrees of freedom. This calculator reports the two-tailed p-value.
How is the regression line related to the correlation coefficient?
The slope of the least-squares regression line is b = r * (sy / sx), where sy and sx are the standard deviations of Y and X. The regression line always passes through the point (x_mean, y_mean). The sign of the slope always matches the sign of r. R2 tells you what fraction of Y's variance the regression line explains. This calculator shows both r and the regression equation y = mx + b so you can use the line to make predictions.
What sample size do I need for a reliable correlation??
As a rule of thumb, n >= 30 gives stable estimates of r. With n = 10, the margin of error around r is very large. The minimum detectable correlation at 80% power and alpha = 0.05 requires roughly n = 25 for r = 0.5, n = 85 for r = 0.3, and n = 783 for r = 0.1. Small samples frequently produce inflated r values by chance. Always report both r and n so readers can assess the reliability of your result.
What is the difference between Pearson r and Spearman rho?
Pearson r measures the linear relationship between two continuous, normally distributed variables. Spearman rho measures the monotonic (not necessarily linear) relationship between two variables based on their ranks. Use Spearman rho when: the data is ordinal (ratings, ranks), the relationship is clearly non-linear but monotonic, or when outliers are present and you want a more robust measure. This calculator computes Pearson r; use the Coefficient of Determination Calculator to explore R2 further.
When should I not use Pearson r?
Pearson r is not appropriate when: (1) the relationship is non-linear (e.g. quadratic), as r can be near 0 even for a perfect curve; (2) the data contains extreme outliers, which can inflate or deflate r dramatically; (3) the variables are ordinal rather than continuous (use Spearman rho); (4) you are comparing groups rather than looking for a linear trend (use ANOVA); (5) the data has a restricted range (range restriction attenuates r).
Can r be negative if both variables are increasing?
Yes, if you define the variables differently or if there is an indirect relationship. For example, if X = distance from city center and Y = income, X increases as you move further out, but Y might decrease (inverse relationship), giving a negative r. The sign of r depends purely on whether the variables move in the same direction (positive) or opposite directions (negative) when examined together across all data points, not on whether each variable individually increases.
How do I use the Summary Statistics mode?
The Summary Statistics mode lets you compute r when you already have n, SumX, SumY, SumX2 (sum of X-squared), SumY2 (sum of Y-squared), and SumXY (sum of products) from a textbook problem or published study. Enter these six values and click Calculate. This is useful for homework problems that give summary statistics rather than raw data, or when you want to verify a published r value. The results include the full regression line and p-value.