Lags and Moving Averages: Key Elements of a Forecast
On this page
Can a single exceptional day throw off your predictions for weeks?
Let's plan an exchangeDiscover our sales forecasting softwareLagged variables, or lags, are past values provided to the model as reference points: sales from seven days ago, sales from last year. Moving averages summarize a recent period, such as the last 28 days. An abnormal day that slips into this period can skew subsequent forecasts if it is not flagged.
The Essentials
- A lagged variable is a past value; a moving average summarizes a recent window of data.
- These are very useful benchmarks, provided they are known at the time of planning.
- Closures, stockouts, or one-off promotions must be excluded; otherwise, the exception becomes the norm.
In 6 Questions
Past values used as benchmarks.
Data scientists, forecasters, pricing managers.
Preparing data for a forecasting model.
Not only on sales, but also on prices.
Give the model the current level and momentum of sales.
Through lags aligned with the rhythms of retail.
The Main Time-Based Reference Points
These benchmarks are among the explanatory variables in a model. They are calculated using the time series data for the product.
| Landmark | Example | What it offers |
|---|---|---|
| Lagged variable | Same-Day Sales, Previous Week | The Weekly Schedule |
| Annual Discrepancy | Sales for the same week last year | Seasonality |
| Moving average | Average sales over the last 28 days | The recent level, without the fluctuations |
| Deviation from the mean | Weekly sales compared to the monthly average | Acceleration or deceleration |
The Trap of Unusual Days
A model learns from what it is shown. If an unusual day is used as a reference point, it treats it as a normal day.
A store that closed for one day for inventory did not lose any customers. In the data, however, it counts as a day with zero sales. Seven days later, that zero serves as a benchmark for forecasting sales on the same day of the week.
The effect is long-lasting: the day remains within the 28-day average for four weeks and within the quarterly average for three months.
The solution is to flag these days and exclude them from the calculation of averages. Our article on exogenous events in sales forecasting explains which ones to identify.
Stockouts pose the same problem, which is addressed by unconstrained demand.
Time Lag and Forecast Horizon
A reference point is usable only if it is known at the time the forecast is calculated.
When forecasting four weeks ahead, sales figures from the day before the target date are not available. Only figures that are at least four weeks old are included.
Using reference data in training that is more recent than the data used in the actual service constitutes a data leak. Time-based validation makes it possible to detect this before deployment.
Lagged price variables
Prices can be treated in the same way as sales, with a direct impact on pricing.
- The previous price: It serves as a reference point for the customer, who compares a price to what they have already paid.
- How long the price has beenin effect: A price that has remained unchanged for a year is not perceived as having changed last week.
- Recent average price: This compares today's price to the usual price.
- The latest promotion: its duration and scope influence the response to the next one, as illustrated by the concept of a strikethrough price.
Our belief: These items are valuable because of the care taken in cleaning them, rather than because of their quantity. This preparation is part of our AI-powered sales forecasting.
See also in the glossary:ARIMA and exponential smoothing · global model · MSE and RMSE · intermittent demand
Frequently Asked Questions
Short answers to the most frequently asked questions about lagged variables.
What is a lagged variable?
A lagged variable is a past value of a data point, provided to the model as a reference point for forecasting. Examples include sales from seven days ago, sales from the same week last year, or prices from the previous month. This reflects a simple idea: what has happened recently provides insight into what will happen next. Lag variables are among the most useful pieces of information for a sales forecasting model.
What is a moving average?
A moving average is the average of data over a shifting time window—for example, sales over the last 28 days. Each day, the window shifts: the oldest day is removed, and the most recent day is added. It summarizes recent sales levels by smoothing out day-to-day fluctuations. Multiple moving averages are often calculated—for a week, a month, and a quarter—to provide the model with both the immediate trend and the underlying trend.
Which lags should you choose?
Those that align with business cycles. A seven-day lag compares one Saturday to another. A one-year lag compares one back-to-school week to the previous back-to-school week. Shorter lags capture recent trends. The choice also depends on the forecasting horizon: only values already known at the time of the calculation can be used. Industry expertise guides this choice better than an automated search.
Why is an abnormal day a problem?
Because it spreads. A day marked by a closure, a disruption, or a special promotion generates an unusual value. This value then reappears as a reference point in forecasts for the following days and is included in all the moving averages that incorporate it for weeks. The model then treats the exception as the norm. These days must be flagged and either excluded from the calculation of averages or replaced with a representative value.
What is the relationship between lagged variables and the forecast horizon?
A direct link. If the forecast must be generated four weeks in advance, sales figures from the day before the forecast date are not yet known: only data that is at least four weeks old can be used. Training a model with more recent data than it will have available in production skews its evaluation. This is a form of data leakage. Lagged variables are therefore always defined relative to the actual decision horizon.
Should prices be lagged as well?
Yes, this is often very helpful. The price from the previous week, the time that has elapsed since the last price change, or the average price over the past few months reflect what the customer has in mind. A product that has been sold for 4.90 euros for a year is not perceived in the same way as a product that dropped from 5.50 to 4.90 euros last week. These variables help the model distinguish between the effect of a price and the effect of a price change.
How does this differ from exponential smoothing?
Exponential smoothing is a comprehensive forecasting method: it generates the forecast itself based on a weighted average of past data. Lagged variables and moving averages are merely inputs fed into a model that combines them with other information, such as price or timing. Both are based on the same intuition—that the recent past sheds light on the future—but they do not play the same role in the forecasting process.
Key Takeaways
- Lagged variables and moving averages provide the model with historical benchmarks.
- Abnormal days must be excluded, or else the forecasts will be skewed for weeks.
- When applied to prices, they distinguish between the effect of a price and the effect of a price change.
Would you like forecasts that are no longer skewed by an exceptional day?
Booper works with your teams to identify unusual days before establishing the benchmarks for its forecasts.
Let's talk about your sales data →Discover our sales forecasting softwareThese articles can interest you
An exogenous event (weather, calendar, trend, competitor’s action) affects demand without appearing in the historical data. Not all of these events warrant inclusion in the model: their weight varies depending on the category and season.
Our position: An exogenous factor is only meaningful if it influences a decision—often a price. We use weather forecasts for the short term, adjust for movable holidays before making comparisons, and monitor trends and competitors.
How much historical data is needed for forecasting? It depends on the category, but reliability matters more than depth: historical data in which breaks, promotions, and price changes are dated is better than a long, unprocessed data set.
Two factors are often overlooked: the history of prices paid—without which elasticity cannot be measured—and the years of inflation, as reflected in volume figures. The adjustment begins with the items that account for the bulk of sales.
AI-based sales forecasting estimates demand for each product, store by store, by separating baseline demand from promotional demand. AI takes in more data points than a spreadsheet, but its value lies solely in the decisions it helps inform.
In retail, this decision is primarily about pricing or a promotion. A useful pricing forecast—one that estimates how much will be sold at each considered price—is evaluated based on its bias rather than its MAPE, and is validated against control stores.