Skip to content

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.

0 valid points detected

Your calculations will appear here

How to Use the Correlation Calculator

  1. 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.
  2. 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.
  3. Results update automatically as you type. The scatter plot with regression line provides a visual representation.
  4. 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?
Correlation measures the strength of a linear relationship between two variables but does not imply that one causes the other. A strong correlation could be due to a confounding variable or coincidence.
What does a Pearson r of 0 mean?
It means there is no linear relationship between the variables. However, there could still be a non-linear relationship (e.g. a quadratic or circular pattern).
How many data points do I need?
A minimum of 2 is required mathematically, but for meaningful results, at least 10 to 20 data points are recommended. With very few points, the correlation can be misleading.
Can I use this for non-linear data?
The Pearson r only measures linear relationships. For non-linear data, consider Spearman rank correlation or transform your data before computing Pearson r.
What are common thresholds for interpreting r?
Common guidelines: |r| < 0.3 is weak, 0.3 to 0.5 is moderate, 0.5 to 0.8 is strong, and above 0.8 is very strong. These thresholds vary by field.

Related Statistics Calculators

Related Articles