Skip to content

Linear regression

Linear regression draws the straight line that best follows the points of two variables, to estimate one from the other: y = a + b·x.

Select any words here to ask your Maestro about them.

With 24 days from 64 to 93 °F, the line explains 96% of the variation in sales (R² = 0.96). How well does it predict a 40 °F day?

24 days of sales, from 64 to 93 °F. Example data.

What it's for: estimating one number from another: how much you'll sell given the temperature, what a house costs given its square footage, how long a delivery takes given the distance. The slope tells you how much one changes for each unit of the other.

Before you trust it: plot the points on a scatter plot. If they don't follow a straight line, the line lies even though Excel hands you an equation. Check for outliers, which pull it.

A line that follows the points well measures a correlation, not a cause. With several variables at once it's called multiple linear regression, one of the simplest machine learning models.

Practice it in When to use a scatter plot.

How it's used

How to get it in Excel

Named ranges: temp (B2:B25) and cups (C2:C25)

  1. marked: =SLOPE(cups,temp)
  2. 3.54Extra cups for each degree.
  3. =INTERCEPT(cups,temp)
  4. −162.7The intercept: with the slope, it gives you the line's equation.
  5. =FORECAST.LINEAR(85,cups,temp)
  6. 138What it predicts for an 85 °F day.
  7. =RSQ(cups,temp)
  8. 0.96How much of the variation the line explains, from 0 to 1.
To name the ranges, select B2:B25 and type temp in the Name Box (left of the formula bar); do the same with C2:C25 and cups. On a scatter plot, right-click the points › Add Trendline › Linear, and check Display Equation on chart.

When to look closer

One day that moves the line

You added a street-fair day with 300 cups to your 24 days. Can a single day change the line much?

Ask your Maestro about Linear regression

It answers from the free course page closest to this word, the way it answers while you study.

Example

You: What does "Linear regression" mean, in plain words?

Your Maestro: I'll explain it with a case of yours: it sticks better than a definition. Which number at work would you like to estimate from another?

Asking about: Answers from the page "Did it go up 2% or 2 points? Percentage points vs. percent"

Only this browser keeps what you ask here. How it works

Learn more

  • Scatter plot

    A scatter plot draws one dot per case, with one variable on each axis, to show whether two numbers move together: when one goes up, does the other go up, go down, or do nothing?

  • Correlation

    Correlation measures how closely two numbers move together, from −1 to 1. Near 1: when one rises, so does the other. Near 0: no straight-line link.

  • Outlier

    An outlier is a value that sits far from the rest, like a $9,800 order among $300 ones. It can be a data-entry error or a real, important case: before you drop it, find out which.

  • Machine learning

    Machine learning has a program learn rules from examples that come with answers, instead of someone writing them, so it can predict new cases.

The whole glossary