Simple Linear Regression

Lesson4 min readQuantitative Forecasting

Simple linear regression fits a straight line through data to describe how one variable (y, such as demand) depends on another (x, such as time, price or advertising). In forecasting, it is used for two jobs: projecting a trend over time, and estimating a cause-and-effect relationship between a driver and demand.

The model

y = a + b × x

Here b is the slope (change in y for each one-unit increase in x) and a is the intercept (the value of y when x is zero). The line is chosen by the method of least squares, which minimizes the sum of squared differences between actual and fitted values.

b = ( nΣxy − ΣxΣy ) ÷ ( nΣx² − (Σx)² ) a = ( Σy − bΣx ) ÷ n

Worked example

Monthly demand (units) for five months, with x = month number:

Month (x) Demand (y) x × y x²
1 20 20 1
2 24 48 4
3 27 81 9
4 33 132 16
5 36 180 25
Σ 140 461 55
  • b = (5×461 − 15×140) ÷ (5×55 − 15²) = (2,305 − 2,100) ÷ 50 = 4.1
  • a = (140 − 4.1×15) ÷ 5 = 15.7

Demand = 15.7 + 4.1 × month

Demand grows about 4.1 units per month. Forecasts: month 6 = 15.7 + 4.1×6 = 40.3, month 7 = 15.7 + 4.1×7 = 44.4.

How good is the fit?

The fitted values are 19.8, 23.9, 28.0, 32.1 and 36.2. The residuals (actual − fitted) are 0.2, 0.1, −1.0, 0.9 and −0.2, giving a sum of squared errors of 1.9. The total variation around the mean (28) is 170, so:

R² = 1 − 1.9 ÷ 170 ≈ 0.989

R² says that about 99 percent of the variation in demand is explained by the line. High R² on five points is encouraging but not proof: with so little data a good fit can be a coincidence.

Using regression with a driver

Instead of time, x can be a business driver, for example price, promotion spend or temperature. Then b tells you how much demand changes per unit of the driver, which is useful for what-if planning. Always remember correlation is not causation, so check that a real mechanism connects the two.

Assumptions and checks

  • The relationship is roughly linear. Plot the data first.
  • Residuals are random, without patterns or growing spread.
  • No big outliers dominating the fit.
  • Don’t forecast far outside the range of x you have data for (extrapolation risk).
  • Trend regression does not capture seasonality. Remove it first or use Holt-Winters.

Regression vs. smoothing methods

Linear regression (trend) Holt’s model
Treats old and new data Equally New data counts more
Adapts to changes in slope Slowly Faster
Good for Stable long-run trends, driver analysis Trending data that shifts

Common mistakes

  • Relying on R² alone without looking at a chart.
  • Extrapolating far beyond the data.
  • Ignoring seasonality in the residuals.
  • Mistaking correlation for causation.

Key takeaways

  • Regression fits y = a + bx by least squares.
  • Slope b is the change in demand per unit of x.
  • Check R², residuals and the range of data before trusting a forecast.
  • Use it for trends and for driver-based planning.

Put it into practice

Ready-made tools that apply this topic:

Browse all templates and bundles →

Frequently asked questions

What is simple linear regression in forecasting?

It fits a straight line y = a + bx through historical data to project a trend over time or to estimate how a driver such as price or promotion affects demand.

How do you calculate the slope and intercept?

Slope b = (nΣxy − ΣxΣy) ÷ (nΣx² − (Σx)²) and intercept a = (Σy − bΣx) ÷ n. For the five-month example the slope is 4.1 and the intercept is 15.7.

What does R-squared mean?

R² is the share of the variation in the dependent variable explained by the model. An R² of 0.99 means the line explains about 99 percent of the variation in the sample.

What is the difference between trend regression and Holt's model?

Regression gives all periods equal weight and fits a fixed line. Holt's model updates level and trend as new data arrives, so it adapts faster to changes.

What are the limits of linear regression for forecasting?

It assumes a linear relationship, can be thrown off by outliers, does not model seasonality on its own and is unreliable when extrapolated far beyond the observed data.