calculatorgate.com
Home
/Correlation & Regression

Correlation and Regression Calculator

Find the correlation coefficient, R² and the regression line for two sets of numbers. Enter your X and Y values, and see how strongly they move together and what Y to expect for a new X.

Last updated: November 15, 2026 · Written by the CalculatorGate team

Example: study hours and exam scores

Results for X = 1, 2, 3, 4, 5 (hours) and Y = 52, 58, 61, 70, 74 (scores):

Correlation coefficient (r)0.99
Coefficient of determination (R²)0.98
Regression equationy = 5.6x + 46.2
Predicted score for 6 hours79.8

About Correlation and Regression Analysis

Understanding the relationship between two variables

Correlation and regression analysis are statistical methods for examining the relationship between two variables. Correlation measures the strength and direction of the relationship, while regression is used to model how one variable affects another.

Correlation coefficient (r): Ranges from -1 to +1. Positive value = variables increase together, negative value = one increases while other decreases, close to 0 = weak relationship. For example, study hours and exam scores typically have positive correlation.

Regression analysis and applications: Regression equation (y = mx + b) enables future predictions. R² value shows how well the model explains (0-1 range, close to 1 = good model). Applications: Sales forecasting (advertising spend → sales), academic performance (study time → grades), economic analysis (GDP → consumption), health research (age → risk factors).

Correlation and regression formulas

  • r = Σ(x − x̄)(y − ȳ) ÷ √[Σ(x − x̄)² × Σ(y − ȳ)²]
  • Slope m = Σ(x − x̄)(y − ȳ) ÷ Σ(x − x̄)²
  • Intercept b = ȳ − m × x̄
  • Regression line: y = m × x + b, and R² = r²
  • x̄, ȳ = the averages of the X and Y values
  • Σ = the sum over all data pairs
  • r = correlation coefficient, from −1 to +1

Worked example: study hours and exam scores

Five students studied 1, 2, 3, 4 and 5 hours and scored 52, 58, 61, 70 and 74. How strong is the link, and what score would 6 hours predict?

  1. Averages: x̄ = 3 hours and ȳ = 63 points.
  2. Sums of deviations: Σ(x − x̄)(y − ȳ) = 56, Σ(x − x̄)² = 10 and Σ(y − ȳ)² = 320.
  3. r = 56 ÷ √(10 × 320) = 0.99, a very strong positive correlation (R² = 0.98).
  4. Slope m = 56 ÷ 10 = 5.6 and intercept b = 63 − 5.6 × 3 = 46.2, so y = 5.6x + 46.2.
  5. Prediction for 6 hours: 5.6 × 6 + 46.2 = 79.8 points.

When to use it

  • Checking whether two measurements move together, like ad spend and sales.
  • Making a simple forecast from past data with the regression line.
  • Statistics homework and checking results worked out by hand.
  • Testing a trend before you put it in a report or presentation.

Common mistakes

  • Reading correlation as cause: ice cream sales and sunburns both rise in summer, but one doesn't cause the other.
  • Trusting a high r from very few pairs: with 3 or 4 points a strong result can happen by chance.
  • Breaking the pairs: X and Y must stay in matching order, and one shifted value changes the whole result.
  • Predicting far outside your data: the line may not hold for an X much larger or smaller than the ones you measured.

Frequently asked questions

Short answers to common questions

What does correlation coefficient show?

Correlation coefficient (r) shows the strength and direction of linear relationship between two variables. It ranges from -1 to +1.

What is R² (R-squared)?

R² (coefficient of determination) shows how much of the variation in the dependent variable is explained by the independent variable. It ranges from 0 to 1, closer to 1 means better model.

How to use regression equation?

Regression equation (y = mx + b) allows you to predict Y value given X value. For example, you can predict sales given advertising spending.

Does correlation show causation?

No! Correlation only shows there's a relationship, not causation. For example, ice cream sales and drowning incidents may correlate but one doesn't cause the other (both increase in hot weather).