Correlation and Regression: Difference Formulas and Examples

#Correlation and Regression
TL;DR
Correlation and regression both study two linked variables: correlation measures how closely, regression describes how one changes with the other. This guide covers r, the regression line, their differences, and six examples.
Madhukar V·reviewed by
PK
Prabhjot KaurLast updated on November 25, 20268 min read

Key Points

  • Correlation measures the strength and direction of a straight-line relationship between two variables with a single number, r, from −1 to 1.
  • Regression fits an equation, ŷ = a + bx, that predicts one variable from the other.
  • Correlation is symmetric, so r is the same whichever variable is called x, but regression of y on x differs from regression of x on y.
  • The square of r, written r², gives the proportion of the variation in y explained by the regression line.
  • A strong correlation does not show that one variable causes the other, since a third factor may drive both.

Two Questions About One Scatter Plot

Students who revise longer tend to score higher, but how much higher, and how reliably?

"How reliably" is a question for correlation. "How much higher" is a question for regression. Both start from the same scatter plot, and together they are the main tools for studying two numerical variables.

correlation and regression on one scatter plot.
Scatter plot of revision hours from 1 to 8 against test scores for 8 students, rising from 52 to 78, with a dashed regression line y-hat equals 48.96 plus 3.54x and the label r equals 0.97.

What Is Correlation?

Correlation measures how closely points cluster around a straight line. The Pearson correlation coefficient is

r=SxySxx Syyr = \frac{S_{xy}}{\sqrt{S_{xx}\,S_{yy}}}

where Sxy=∑(x−xˉ)(y−yˉ)S_{xy} = \sum (x - \bar{x})(y - \bar{y}), Sxx=∑(x−xˉ)2S_{xx} = \sum (x - \bar{x})^2 and Syy=∑(y−yˉ)2S_{yy} = \sum (y - \bar{y})^2. The correlation coefficient formula page sets out the calculation step by step.

different values of the correlation coefficient.
Three scatter plots of simulated data: strong positive correlation with r about 0.9, no linear relationship with r about 0, and strong negative correlation with r about minus 0.9.

Values near 1 mean a strong rising pattern, near −1-1 a strong falling one, and near 0 no straight-line pattern. For the revision data, r≈0.97r \approx 0.97.

Try It Yourself

Use the scatter and best fit to see Correlation and Regression at work: drag, change the numbers and watch what happens.

What Is Regression?

Regression fits the line that best predicts yy from xx:

y^=a+bx,b=SxySxx,a=yˉ−bxˉ\hat{y} = a + bx, \qquad b = \frac{S_{xy}}{S_{xx}}, \qquad a = \bar{y} - b\bar{x}

For the revision data, y^=48.96+3.54x\hat{y} = 48.96 + 3.54x. The slope, 3.54, is the predicted gain in score for each extra hour. The line is found by the least squares method, which makes the squared prediction errors as small as possible.

How Are Correlation and Regression Different?

They answer different questions.

correlation and regression compared.
Table comparing correlation and regression: correlation asks how strongly x and y are linked, gives a coefficient r from minus 1 to 1, is symmetric, and measures association; regression asks how y changes with x, gives an equation y-hat equals a plus bx, is not symmetric, and is used to predict.

They are linked: the slope equals r×sysxr \times \frac{s_y}{s_x}, so they always have the same sign. And r2r^2 is the share of the variation in yy that the line explains: 0.972≈0.950.97^2 \approx 0.95, so about 95 percent here.

Examples of Correlation and Regression

Example 1

Using the line y^=48.96+3.54x\hat{y} = 48.96 + 3.54x, predict the score of a student who revises for 6 hours.

y^=48.96+3.54×6≈70.2\hat{y} = 48.96 + 3.54 \times 6 \approx 70.2.

Example 2

A city finds that ice cream sales and swimming accidents are strongly correlated. Should it limit ice cream sales to reduce accidents?

The strong correlation seems to suggest one drives the other.

Both rise in hot weather. Temperature is a third variable, a confounder, that causes both, so cutting ice cream sales would not prevent accidents. Correlation shows association, not cause.

correlation and regression do not prove causation.
Diagram of hot weather causing both rising ice cream sales and rising swimming accidents, with a dashed line between the two effects labelled linked, but neither causes the other.

Example 3

If r=−0.8r = -0.8, describe the relationship.

A strong negative linear relationship: as one variable rises, the other tends to fall.

Example 4

For the revision data, what proportion of the variation in scores does the line explain?

r2≈0.95r^2 \approx 0.95, about 95 percent.

Example 5

Use the line to predict the score for 20 hours of revision.

The formula gives about 120, which is impossible on a 100-mark test. The data only cover 1 to 8 hours, and extending the line far beyond them, called extrapolation, is unreliable.

Example 6

Two variables have r=0r = 0. Are they unrelated?

Not necessarily. rr measures only straight-line relationships. A U-shaped pattern can have rr near 0 but a strong curved relationship.

Why Correlation and Regression Matter

They are the starting point for studying relationships in data.

  • Prediction. Regression turns a relationship into a formula for estimates.
  • Measuring strength. Correlation summarises a scatter plot in one comparable number.
  • Explaining variation. r2r^2 shows how much of the spread in yy a variable accounts for.
  • Building larger models. Multiple regression extends the same idea to several predictors.

OpenStax's Regression Equation section computes the line of best fit and the correlation coefficient together, as this article does.

What Most Guides Get Wrong About Correlation and Regression

Two points are often missed.

The first is causation. Many guides mention "correlation is not causation" in passing. Example 2 shows why it deserves more weight: confounders are common, and a regression line drawn through confounded data predicts well while explaining nothing about cause.

The second is the range of the data. Regression lines are often extended freely. Example 5 shows the danger: a line that fits well from 1 to 8 hours gives a nonsense prediction at 20. Predictions are trustworthy only within, or close to, the range of the data.

Where Students Trip Up on Correlation and Regression

Mistake 1: Reading correlation as cause

Where it slips in: Interpreting strong correlations, as in Example 2.

Don't do this: Concluding that xx causes yy because rr is large.

The correct way: Look for confounding variables, and use experiments to establish cause.

Students read cause into correlation because a tight scatter plot looks like a mechanism, and the third variable is never shown on the graph.

Mistake 2: Extrapolating far beyond the data

Where it slips in: Predictions, as in Example 5.

Don't do this: Using the line far outside the observed range.

The correct way: Keep predictions within the range of the data, and state the range.

Mistake 3: Taking r = 0 as "no relationship"

Where it slips in: Curved patterns, as in Example 6.

Don't do this: Ignoring a clear curve because rr is small.

The correct way: Always look at the scatter plot as well as rr.

The word "regression" comes from Francis Galton's work in the 1880s on the heights of parents and children: very tall parents tended to have children closer to average height, a pattern he called regression towards the mean.

Key Takeaways

  • Correlation and regression study how two numerical variables move together.
  • Correlation gives rr, from −1-1 to 11; regression gives the line y^=a+bx\hat{y} = a + bx.
  • r2r^2 is the share of variation explained, and the slope has the same sign as rr.
  • Neither proves cause, and predictions should stay within the data's range.
  • To work through statistics with a teacher, explore Bhanzu's high school math tutor sessions or math classes online.

A Practical Next Step

Record the height and arm span of eight friends. Plot them, compute rr and the regression line of arm span on height, and use it to predict the arm span of someone 160 cm tall. Then check whether that height lies within your data's range.

Practice these to solidify your understanding. If a strong r still looks like proof of cause, return to Example 2. Want a live Bhanzu trainer to walk through more statistics problems? Book a free demo class, online globally, or in person at our McKinney, TX center.

Read More

Research Behind This Article

  1. OpenStax, Introductory Statistics 2e, 12.2 Scatter Plots (2023). openstax.org
  2. OpenStax, Introductory Statistics 2e, 12.4 Testing the Significance of the Correlation Coefficient (2023). openstax.org
  3. NIST/SEMATECH, e-Handbook of Statistical Methods, 4.1.4.1 Linear Least Squares Regression (2022). itl.nist.gov
  4. NIST/SEMATECH, e-Handbook of Statistical Methods, 1.3.3.26 Scatter Plot (2022). itl.nist.gov
  5. University of St Andrews, MacTutor History of Mathematics: Francis Galton. mathshistory.st-andrews.ac.uk

Quick Quiz: Check Yourself

Three levels, fresh numbers every time, instant feedback with the working.

Was this article helpful?

Your feedback helps us write better content

Frequently Asked Questions

What is the difference between correlation and regression?
Correlation measures how strongly two variables are linearly related. Regression gives an equation for predicting one variable from the other.
What does the correlation coefficient r tell you?
The strength and direction of a straight-line relationship, from −1-1 to 11.
What is a regression line?
The line y^=a+bx\hat{y} = a + bx that best predicts yy from xx, usually found by least squares.
Does correlation and regression show causation?
No. Both describe association. Cause needs controlled experiments or careful reasoning about other variables.
What is r squared in correlation and regression?
The proportion of the variation in yy explained by the regression line.
✍️ Written By
Madhukar V
Madhukar V
Math Columnist & Analyst
I see mathematics as more than just numbers and formulas—it is a way of thinking, questioning, and understanding the world around us. I work at the intersection of mathematics, EdTech, technology, and AI-powered learning, I enjoy exploring how mathematical ideas can be made simple, meaningful, and relatable. Through my articles, I aim to present mathematics with curiosity and a practical perspective, helping readers see the beauty and relevance behind every concept in a Bhanzu way.
LinkedIn
🔬 Reviewed By
PK
Subject Matter Expert & Curriculum Developer
Book a FREE Demo ClassBook Now →