Moving average forecast: how to choose the length, with example
A moving average forecast predicts the next period as the average of the last k observations. Each new observation enters the average and the oldest one drops out, so the forecast follows the level of the series while smoothing out random ups and downs. It suits series that wander around a level without a clear trend or season, such as weekly demand for a spare part, and it is easy to explain to anyone who plans from it.
When to use it
- The series has no strong trend or seasonal pattern on a time series plot.
- You need a short-term forecast (the next period or a few) for inventory, staffing or material planning.
- You want a method anyone can check with a calculator.
- You want a baseline to compare more elaborate methods against.
If the series trends, a moving average will lag behind it; use trend analysis or double exponential smoothing. If you want recent weeks to count more than older ones, use single exponential smoothing.
How it works
With a moving average of length k, the forecast for period t + 1 is the mean of periods t − k + 1 through t:
F(t+1) = (yₜ + yₜ₋₁ + … + yₜ₋ₖ₊₁) / kEach of the last k observations gets weight 1/k, and older ones get none. The forecast for every future period is the same flat value, because the method has no trend term.
The fitted values are the one-step-ahead forecasts, so the first k periods have none. Accuracy is measured on the errors eₜ = yₜ − F(t):
MAPE = (100/m) · Σ |eₜ / yₜ| MAD = (1/m) · Σ |eₜ| MSD = (1/m) · Σ eₜ²where m is the number of periods with a forecast. A short length reacts quickly to real changes but also chases noise; a long length is smooth but slow. Compare lengths on the same set of periods, since a longer average has fewer forecasts.
A trailing average is not the same as a centered one. A centered moving average, used in decomposition, puts the average in the middle of its window to show the trend; it cannot forecast, because it needs future values.
Example
A maintenance storeroom tracks weekly use of a hydraulic seal kit for 20 weeks:
| Weeks | Kits used |
|---|---|
| 1–5 | 124, 130, 124, 104, 131 |
| 6–10 | 125, 114, 127, 124, 124 |
| 11–15 | 120, 127, 126, 133, 129 |
| 16–20 | 142, 135, 131, 126, 132 |
With k = 4, the forecast for week 5 is (124 + 130 + 124 + 104) / 4 = 120.5. Week 5 used 131, an error of +10.5. Continuing:
Over weeks 5 to 20, the 4-week forecast has MAPE 3.81%, MAD 4.92 kits and MSD 38.19. The forecast for week 21, and for every week after it until new data arrive, is the mean of weeks 17 to 20: (135 + 131 + 126 + 132) / 4 = 131.0 kits.
The chart shows the main weakness. Use averaged 122.8 kits a week in weeks 1 to 12 and 131.8 in weeks 13 to 20, after a second production line started using the same kit. The forecast stayed below the actual use for weeks 13 to 16 and needed about four weeks, one full window, to catch up.
To choose the length, the storeroom compares several on the same weeks (7 to 20):
| Length k | MAPE | MAD | MSD |
|---|---|---|---|
| 2 | 4.20 | 5.32 | 42.52 |
| 3 | 3.52 | 4.52 | 33.17 |
| 4 | 3.62 | 4.68 | 35.23 |
| 6 | 4.12 | 5.30 | 41.45 |
Lengths 3 and 4 do about equally well. Length 2 chases noise, such as the dip in week 7, and length 6 is slow to follow the step up. The storeroom keeps k = 4 because it smooths a little more with almost the same accuracy, and sets the reorder point from the 131-kit forecast plus safety stock.
How to read the results
- The forecast is a flat line at the last moving average. It says "about this much per period", not "rising" or "falling".
- The accuracy measures describe one-step-ahead errors on the past data. MAD in the data's units is often the easiest to use for safety stock.
- A run of same-signed errors means the level has shifted or the series trends; the forecast is lagging.
Common mistakes
- Using it on trending data. Every forecast lags the trend by about (k + 1)/2 periods, so it is always behind.
- Comparing lengths on different periods. Longer averages skip more early periods; compare them on a common window.
- Picking the length with the lowest MSD by a hair. Small differences are noise; prefer the length that matches how fast real changes happen.
- Confusing it with a moving average control chart. A moving average chart adds control limits to detect shifts; this method only forecasts.
Frequently asked questions
How long should the moving average be?
Long enough to smooth the noise and short enough to follow real changes. Try several lengths on the same periods and pick one with low error that also makes sense for the process, such as 4 weeks for a monthly rhythm.
Why is the forecast the same for every future period?
The method only estimates the current level. Without a trend or a season, the best guess for week 22 is the same as for week 21.
How does it compare with single exponential smoothing?
Both forecast a flat level. Exponential smoothing weights all past data, with weights that shrink with age, so it reacts smoothly and never drops an observation abruptly. In practice their accuracy is often similar.
Can I use a weighted moving average?
Yes. Giving recent periods larger weights makes the forecast react faster. Exponential smoothing is the most common version of that idea.