Correlation Coefficient Calculator
Calculate Pearson correlation coefficient, R-squared, p-value, strength description, and linear regression equation from paired data.
Correlation Coefficient Calculator
Calculator
Adjust values & calculateEnter your values below. Every result is computed in your browser — no data is sent to any server.
Formula: r = [n(Sum_XY) - (Sum_X)(Sum_Y)] / sqrt{[n(Sum_X2) - (Sum_X)2][n(Sum_Y2) - (Sum_Y)2]}
Worked example — r = 0.993 | R2 = 98.7% | Very strong positive correlation
Formula
r = [n(Sum_XY) - (Sum_X)(Sum_Y)] / sqrt{[n(Sum_X2) - (Sum_X)2][n(Sum_Y2) - (Sum_Y)2]}Pearson's r is computed by dividing the covariance of X and Y by the product of their standard deviations. The formula uses sums of products, sums of squares, and sample size n. R-squared = r squared. The regression line uses y = slope * x + intercept where slope = r * (Sy/Sx).
Worked Examples
Example 1: Study Hours vs. Test Score
Problem:Data: (1,50), (2,55), (3,65), (4,70), (5,75), (6,80), (7,85). Calculate the correlation.
Solution:Pearson r = 0.9934 (very strong positive) R-squared = 98.7% of score variance explained by hours Regression: Score = 5.89 × Hours + 44.29 Each additional hour predicts ~5.9 more points.
Result:r = 0.993 | R2 = 98.7% | Very strong positive correlation
Example 2: Temperature vs. Ice Cream Sales
Problem:Data: (60,100), (65,120), (70,150), (75,200), (80,250), (85,300), (90,350).
Solution:r = 0.994 (very strong positive) R-squared = 98.8% Regression: Sales = 8.21 × Temp - 402.14 Each degree increase predicts ~8 more units sold.
Result:r = 0.994 | R2 = 98.8% | Very strong positive
Frequently Asked Questions
What is Pearson's correlation coefficient (r)?
Pearson's r measures the strength and direction of the linear relationship between two continuous variables. It ranges from -1 to +1. A value of +1 indicates a perfect positive linear relationship, -1 indicates a perfect negative linear relationship, and 0 indicates no linear relationship. It only measures linear associations — two variables can have a strong non-linear relationship but a low Pearson r.
What is R-squared and how do I interpret it?
R-squared (R2) is the square of the correlation coefficient. It represents the proportion of variance in the dependent variable that is explained by the independent variable. For example, r = 0.8 gives R2 = 0.64, meaning 64% of the variance in Y is explained by X. The remaining 36% is unexplained. R2 always ranges from 0 to 1 (or 0% to 100%).
Does correlation imply causation?
No. Correlation measures association, not causation. Two variables can be correlated because: (1) X causes Y, (2) Y causes X, (3) a third variable causes both, or (4) it is a coincidence. Establishing causation requires controlled experiments, temporal ordering, ruling out confounders, and theoretical justification. Always be cautious about inferring causation from correlation alone.
What is the regression equation?
The linear regression equation y = mx + b describes the best-fit line through the data points. The slope (m) indicates how much Y changes for a one-unit increase in X. The intercept (b) is the predicted Y value when X is zero. This equation minimizes the sum of squared residuals (ordinary least squares). Use it to predict Y for new X values within the range of your data.
What is the difference between Pearson and Spearman correlation?
Pearson's r measures linear association between the raw values and assumes roughly interval-scaled data. Spearman's rho applies the same formula to the ranks of the data instead, so it captures any monotonic relationship — consistently increasing or decreasing, even if curved — and is far less sensitive to outliers and skew. Use Pearson when a straight line is a fair description of the scatter; use Spearman for ordinal data or when a few extreme points dominate.
How do outliers distort the correlation coefficient?
Because r is built from products of deviations from the mean, a single point far from the cloud contributes an enormous cross-product and can swing the coefficient dramatically. One extreme observation can push r from near zero to above 0.8, or mask a real relationship by pulling the fit toward itself. Always plot the scatter before trusting r, check whether the influential point is a data-entry error, and report the coefficient with and without it if it is genuine.
Why can r be near zero when the variables are clearly related?
Pearson's r only detects the linear component of a relationship. A perfect U-shaped or parabolic pattern has equal positive and negative slopes on either side of the vertex, so the deviation products cancel and r approaches zero despite a deterministic link. The same happens with cyclical data. A scatterplot, a nonlinear fit, or a transformation such as taking logs of a multiplicative relationship will reveal structure the coefficient misses.
What is the standard error of the estimate telling me?
The standard error of the estimate is the typical vertical distance between observed Y values and the regression line, expressed in the units of Y. It is the square root of the mean squared residual, so a value of 4 on a test-score model means predictions are usually within about 4 points. Unlike R-squared, which is unitless and relative, it gives an absolute sense of prediction accuracy and is what you use to gauge whether the model is precise enough to act on.
How does restricting the range of X weaken the observed correlation?
Range restriction, or truncation, occurs when the sample covers only part of the natural spread of X — for example correlating admission test scores with grades using only admitted students. Narrowing the variance in X shrinks the covariance term far more than the residual scatter, so r falls toward zero even though the underlying relationship is unchanged. Correlations from selected subgroups routinely understate the association present in the full population.
When is extrapolating the regression equation beyond the data unsafe?
The slope and intercept are fitted only to the range of X actually observed, and least squares gives no information about behaviour outside it. Predicting a test score for 20 study hours from data covering 1 to 7 hours assumes the linear trend continues, when real processes usually flatten or saturate. Intercepts are especially misleading when X = 0 is far outside the data, which is why a fitted intercept can be negative even for a quantity that cannot be negative.
References
Reviewed for accuracy by Daniel Agrici, Founder & Lead Developer · Editorial policy
Related Calculators
🧮Descriptive Statistics Calculator
Calculate descriptive statistics with inputs, formulas, and instant results.
🧮Bayesian Posterior Calculator
Calculate bayesian posterior with inputs, formulas, and instant results.
🧮False Discovery Rate Calculator
Calculate false discovery rate with inputs, formulas, and instant results.
🧮Binomial Distribution Calculator
Calculate binomial distribution with inputs, formulas, and instant results.
🧮Chi Square Test Calculator
Calculate chi square test with inputs, formulas, and instant results.
🧮Ztest Proportions Calculator
Calculate ztest proportions with inputs, formulas, and instant results.
🧮Effect Size Calculator
Calculate effect size with inputs, formulas, and instant results.
🧮Power Analysis Calculator
Calculate power analysis with inputs, formulas, and instant results.