Skip to main content

Correlation Calculator

Free Correlation Calculator for statistics. Enter values to get step-by-step solutions with formulas and graphs. Free to use with no signup required.

Reviewed by Manoj Kumar, Mathematics Educator

Reviewed by Manoj Kumar, Mathematics Educator

Formula

r = Sum[(Xi - Xmean)(Yi - Ymean)] / sqrt[Sum(Xi - Xmean)^2 x Sum(Yi - Ymean)^2]

Where Xi and Yi are individual data points, Xmean and Ymean are the means of each dataset, and the summation is over all n data pairs. R-squared equals r squared and represents the proportion of variance explained. The regression line y = mx + b uses slope m = Sum[(Xi-Xmean)(Yi-Ymean)] / Sum[(Xi-Xmean)^2].

Worked Examples

Example 1: Strong Positive Correlation

Problem:Calculate the correlation between study hours (X: 1,2,3,4,5,6,7,8,9,10) and test scores (Y: 52,58,63,71,75,82,85,91,94,98).

Solution:n = 10, X mean = 5.5, Y mean = 76.9\nSum of (Xi - Xmean)(Yi - Ymean) = 437.5\nSum of (Xi - Xmean)^2 = 82.5\nSum of (Yi - Ymean)^2 = 2,340.9\nr = 437.5 / sqrt(82.5 x 2,340.9) = 437.5 / 439.5 = 0.9955\nR-squared = 0.991 (99.1% of variance explained)\nRegression: Y = 5.30X + 47.73

Result:r = 0.9955 (Very Strong Positive) | R-squared = 99.1%

Example 2: Moderate Negative Correlation

Problem:Calculate correlation between temperature (X: 95,88,82,75,68,60,55) and hot chocolate sales (Y: 12,18,25,35,42,55,60).

Solution:n = 7, X mean = 74.71, Y mean = 35.29\nSum of (Xi - Xmean)(Yi - Ymean) = -2,588.57\nSum of (Xi - Xmean)^2 = 1,318.86\nSum of (Yi - Ymean)^2 = 5,248.86\nr = -2,588.57 / sqrt(1,318.86 x 5,248.86) = -0.9837\nR-squared = 0.968 (96.8% of variance explained)\nRegression: Y = -1.963X + 181.92

Result:r = -0.9837 (Very Strong Negative) | R-squared = 96.8%

Frequently Asked Questions

What is correlation and what does the correlation coefficient measure?

Correlation is a statistical measure that quantifies the strength and direction of the linear relationship between two variables, expressed as a coefficient (r) that ranges from -1 to +1. A correlation of +1 indicates a perfect positive linear relationship where both variables increase together, while -1 indicates a perfect negative linear relationship where one increases as the other decreases. A correlation of 0 indicates no linear relationship between the variables. The Pearson correlation coefficient specifically measures how closely the data points fall along a straight line, making it the most commonly used correlation measure in statistics, research, and data analysis across virtually every scientific and business discipline.

What is the difference between Pearson and Spearman correlation?

Pearson correlation measures the linear relationship between two continuous variables and assumes both variables are normally distributed with a linear relationship. Spearman rank correlation measures the monotonic relationship between variables by first converting data to ranks and then computing the correlation of those ranks, making it more robust to outliers and non-linear relationships. Spearman correlation is appropriate for ordinal data (like survey ratings) and when the relationship between variables is monotonic but not necessarily linear. If both Pearson and Spearman correlations are similar, the relationship is likely linear, but if Spearman is notably higher than Pearson, the relationship may be monotonic but curved rather than straight.

What does R-squared mean and how is it different from the correlation coefficient?

R-squared, also called the coefficient of determination, is simply the square of the Pearson correlation coefficient and represents the proportion of variance in one variable that is predictable from the other variable. While the correlation coefficient r tells you the strength and direction of the relationship (ranging from -1 to +1), R-squared tells you what percentage of the variation in Y is explained by X (ranging from 0 to 1 or 0% to 100%). For example, a correlation of 0.80 gives an R-squared of 0.64, meaning 64% of the variation in Y can be explained by its linear relationship with X. R-squared is often preferred in regression analysis because it has a more intuitive interpretation as the percentage of variance explained.

Does correlation imply causation and why is this distinction important?

Correlation does not imply causation, which is perhaps the most important principle in statistical analysis. Just because two variables move together does not mean one causes the other. There are several reasons correlated variables may not be causally related: a third confounding variable may cause both (ice cream sales and drowning deaths both increase in summer due to hot weather), the causal direction may be reversed, or the correlation may be entirely coincidental. Establishing causation requires controlled experiments where one variable is manipulated while others are held constant, temporal precedence showing the cause precedes the effect, and elimination of alternative explanations. This distinction is critical in medicine, policy-making, and business decisions where acting on correlational data as if it were causal can lead to ineffective or harmful interventions.

References

Reviewed by Manoj Kumar, Mathematics Educator ยท Editorial policy