Correlation Calculator — Step-by-Step Solutions
The Correlation Calculator measures the strength and direction of the linear relationship between two variables. It computes the Pearson correlation coefficient (r), the coefficient of determination (R-squared), and the equation of the best-fit regression line.
Enter paired data points as comma-separated (x, y) values, one pair per line. The scatter plot with regression line updates in real time, giving you an immediate visual sense of how strongly your variables are related.
Your calculations will appear here
How to Use the Correlation Calculator
- Select a mode. "Pearson r" computes the correlation coefficient and interprets its strength. "R-Squared" shows how much variance is explained. "Scatter Plot" focuses on the regression line equation.
- Enter your data as x, y pairs, one per line. For example: "1, 2" on the first line, "3, 4" on the second. You need at least two data points.
- Results update automatically as you type. The scatter plot with regression line provides a visual representation.
- Review the step-by-step calculations to understand how the correlation and regression values are derived.
Formula and Theory
The Pearson correlation coefficient (r) measures the strength and direction of the linear relationship between two variables. It ranges from -1 (perfect negative correlation) through 0 (no linear correlation) to +1 (perfect positive correlation). The formula divides the covariance of x and y by the product of their standard deviations.
R-squared (the coefficient of determination) is the square of the Pearson r. It represents the proportion of variance in y that is explained by the linear relationship with x. An R-squared of 0.85, for instance, means 85% of the variability in y can be predicted from x using the regression line.
The least-squares regression line y = mx + b minimises the sum of squared residuals (vertical distances from data points to the line). The slope m equals the covariance of x and y divided by the variance of x. The intercept b ensures the line passes through the point (mean of x, mean of y). Correlation and regression are related but distinct: correlation measures strength; regression provides a predictive equation.
Worked Examples
Example 1: Strong positive correlation
Problem: Given data points (1,2), (2,4), (3,5), (4,4), (5,5), find the Pearson r.
Solution: Mean x = 3, Mean y = 4. Sum of (xi - xbar)(yi - ybar) = 5. Sum of (xi - xbar)^2 = 10. Sum of (yi - ybar)^2 = 6. r = 5 / sqrt(10 * 6) = 5 / 7.746.
Answer: r = 0.6455 (moderate positive correlation)
Example 2: Regression line
Problem: Using the same data, find the equation of the regression line.
Solution: Slope m = 5 / 10 = 0.5. Intercept b = 4 - 0.5 * 3 = 2.5.
Answer: y = 0.5x + 2.5
Example 3: R-squared interpretation
Problem: A study finds r = 0.9 between study hours and exam scores. What is R-squared?
Solution: R-squared = 0.9^2 = 0.81.
Answer: R-squared = 0.81, meaning 81% of the variance in exam scores is explained by study hours
Frequently Asked Questions
What is the difference between correlation and causation?
What does a Pearson r of 0 mean?
How many data points do I need?
Can I use this for non-linear data?
What are common thresholds for interpreting r?
Related Statistics Calculators
Probability Calculator
Calculate probability of events, complements, unions, and intersections. Free online probability calculator for statistics.
Standard Deviation Calculator
Calculate standard deviation, variance, mean, and more for any dataset. Supports population and sample statistics. Free online tool.
Z-Score Calculator
Calculate z-scores, find values from z-scores, and determine probabilities. Free online z-score calculator with bell curve visualisation.
Binomial Calculator
Calculate binomial probabilities, cumulative distributions, and expected values. Free online binomial distribution calculator with bar chart.
Normal Distribution Calculator
Calculate probabilities for normal distributions. Find areas under the bell curve, percentiles, and inverse values. Free online tool.
Permutation & Combination Calculator
Calculate permutations and combinations. Find nPr, nCr, factorials, and arrangements. Free online permutation and combination calculator.