November 23, 2024
By 
Mike Le

Linear Regression for Demand Forecasting

Linear Regression for Demand Forecasting

Regression forecasts demand from drivers like price, promos, and weather. Learn how it works, what R squared tells you, and a worked driver-based example.

Sales do not move on their own. Drop the price, run a promotion, hit a heatwave, and demand reacts, usually by a consistent amount you could predict if anyone had ever measured it. Regression is how you put a number on that reaction instead of describing it in the planning meeting.

Linear regression forecasts demand by quantifying how explanatory variables such as price, promotions, seasonality, and weather drive sales, producing an equation you can plug new values into. R squared shows how much of the demand variation the model explains. It is the method to reach for when an outside factor clearly moves your demand.

Key takeaways

  • It answers a different question from time-series forecasting: not what happens next, but what happens if you change something.
  • The drivers you choose decide the model: a regression is only as good as the variables you thought to include.
  • R squared is a fit measure, not a truth measure: a high value on the wrong drivers is still the wrong model.
  • Its real value is planning, not prediction: you can test a price or a promotion before committing to it.

What is regression analysis in demand forecasting?

Regression forecasting predicts demand by measuring how one or more driver variables move sales, expressed as an equation you can plug new values into. Instead of asking what last year's pattern suggests for next month, it asks what happens to units when price falls by 10% or when a promotion runs, and answers with a coefficient.

That difference in question is the whole reason the method exists alongside time-series forecasting. A time-series model reads the shape of your history and extends it, which works well when next month resembles last month. Regression reads the causes, which is what you need when you are about to change one of them deliberately. If you are planning a promotion, a time-series model can only tell you what demand did during past promotions; a regression can estimate what this one will do at this discount depth.

Demand as a function of drivers. The mental model is simpler than the arithmetic. You are proposing that units sold is a function of a handful of measurable things, and asking the data how much each one contributes. The output is an equation of the form units equals a baseline plus a coefficient for each driver times that driver's value. The baseline is what you would sell with every driver at zero or at its reference level, and each coefficient is the answer to "how much does this one move units, holding the others steady". Once you have those numbers, forecasting becomes a matter of plugging in next month's planned price and promotion schedule.

What are explanatory variables, and which ones matter?

Explanatory variables are the drivers you feed the model, and choosing the right ones decides whether the forecast holds. Include a variable that genuinely moves demand and the model gets sharper. Include one that merely happens to correlate and you have built something that will fail the moment the coincidence ends. This selection step is where most regression forecasts are won or lost, well before any arithmetic.

Common demand drivers for eCommerce

The candidates worth testing first are the ones you both control and record. Price is usually the strongest and the easiest to obtain. Promotion, entered as a simple yes or no flag or as discount depth, is the second. Seasonality, whether as a month indicator or a seasonal index, captures the recurring shape. Marketing activity, most practically ad spend or impressions for that product, catches demand you created rather than demand that was there. Beyond those, competitor pricing and weather matter in specific categories and are noise in most. Start with the first four, because they are the ones you can actually maintain.

Two traps in choosing variables

The first is correlated drivers. Ad spend and promotions often rise together, and when two variables move as one the model cannot tell which is doing the work, so the individual coefficients become unreliable even while the overall fit looks fine. The practical answer is to drop one, or to combine them into a single indicator. The second trap is variables you cannot forecast. A driver is only useful if you will know its value in advance for the period you are forecasting, which is why planned price and scheduled promotions are excellent drivers and next month's competitor pricing is not.

What does R squared tell you about a regression forecast?

R squared is the share of demand variation your model explains, on a scale from 0 to 1, so 0.7 means the drivers you chose account for about 70% of the movement in sales and something else accounts for the rest. Higher means the model captures more of what is really happening, which sounds like an unambiguous good and is not.

Two cautions matter more than the number. First, R squared always rises when you add variables, whether or not those variables mean anything, so a very high value on a model with many drivers may simply be describing your historical noise rather than any real relationship. That model will fit the past beautifully and forecast badly. Second, R squared says nothing about whether your causal story is right. A model can explain 85% of variation using a driver that happens to move alongside the real cause, and it will hold precisely until that coincidence breaks.

The practical test is the same one that applies to any forecast: hold back a period the model has not seen, predict it, and compare against what actually happened. A model that fits history well and predicts a held-out month badly has been overfitted, and no R squared value will tell you that.

A worked driver-based example

Here is regression on a small dataset. A single product, six months of history, two drivers: the average price that month and whether a promotion ran.

  • 1. avg price: $40; promotion: No; units sold: 620
  • 2. avg price: $40; promotion: Yes; units sold: 910
  • 3. avg price: $44; promotion: No; units sold: 540
  • 4. avg price: $36; promotion: No; units sold: 700
  • 5. avg price: $44; promotion: Yes; units sold: 830
  • 6. avg price: $36; promotion: Yes; units sold: 990

Fitting a line to those six points gives an equation of roughly: units = 1,340 minus 18 times price plus 285 times the promotion flag.

Read it in plain terms. The baseline of 1,340 is a mathematical starting point rather than a real scenario, since the product is never free. What matters are the two coefficients. Each dollar of price increase costs about 18 units, so a $4 rise costs roughly 72. Running a promotion adds about 285 units, independent of price.

Now use it. Next month you plan to hold price at $40 and run a promotion. The prediction is 1,340 minus 18 times 40, which is 720, plus 285, giving about 1,005 units. That is a forecast you can defend in a buying meeting, because every part of it traces to something you decided.

Two honest caveats on an example this small. Six data points is far too few for a model you would actually rely on, and the equation is fitted to illustrate the mechanics rather than to be precise. And the relationship is assumed to be a straight line, which real demand often is not: the response to a 40% discount is rarely four times the response to a 10% one.

Where regression fits alongside other methods

Regression is a specialist rather than a default. Use it when you have a clear driver you control and want to test a decision before making it. Use a time-series method when you simply need next period's number and nothing unusual is planned. Use a learned model when there are many interacting drivers and enough history for it to find relationships nobody would hand-code, which is where Conative AI's proprietary deep-learning models operate, reading live marketing signals, ad spend, sales velocity, and campaign events, alongside sales history at the product level. That is regression's logic extended to a signal set no one could maintain by hand, so the demand number moves before the spike rather than after it. Start your free trial to see which drivers matter in your own data on the inventory planning platform.

Frequently asked questions

What's the difference between regression and time-series forecasting?

Time-series forecasting extends the pattern in your own sales history forward. Regression explains demand using outside drivers such as price and promotions, then predicts from those. Use time-series when nothing unusual is planned, and regression when you want to test the effect of a change you are about to make.

How many data points do you need for regression forecasting?

More than most people assume. A common rule of thumb is at least ten to twenty observations per driver, so a two-driver model wants twenty to forty periods at minimum. With weekly data that is manageable; with monthly data it means several years. Too few points and the model fits noise.

What is a good R squared for a demand model?

It depends entirely on category volatility, so there is no universal threshold. Steady products with clear drivers can reach 0.8 or above; volatile categories may top out near 0.5 and still be useful. Judge the model by how it predicts a period it has not seen, not by its fit to history.

Can regression handle multiple demand drivers at once?

Yes, and that is its main strength: multiple regression estimates each driver's effect while holding the others steady. The limit is practical rather than mathematical. Each driver needs enough history to support it and has to be one whose future value you will actually know.

Is regression better than machine learning for forecasting?

Not better, different. Regression is transparent, so you can see exactly what each driver contributes and explain it to someone. Learned models handle many interacting drivers and non-linear relationships that regression cannot, at the cost of being harder to interrogate. Transparency versus flexibility is the real trade.

What happens when two drivers are correlated?

The model struggles to separate their individual effects, so the coefficients become unstable even though the overall fit may look healthy. Ad spend and promotions commonly move together this way. The usual fix is to drop one of them or combine them into a single indicator.

Turn insights into cash

Time is money, save both.

By clicking Get Started you're confirming that you agree with our Terms and Conditions.
Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.