Technology · Forecasting

Time series analysis: forecasts that state their uncertainty

A forecast without a range is no more than an assertion. Time series analysis shows how much of your sales follows a pattern, how much is down to chance and what a forecast error costs.

Time series analysis: definition and scope

Time series analysis studies measurements taken at fixed time intervals, such as weekly sales, daily order intake, or the price of a raw material on each trading day. It splits such a series into three components: the trend as its long-term direction, seasonality as the recurring pattern, and a remainder that neither of the two explains [1]. Trend and seasonality yield the forecast, and the remainder shows how uncertain it is.

Alongside decomposition, there are ARIMA models, which explain a value from its own past values and from earlier forecast errors. George Box and Gwilym Jenkins popularized them in 1970 with their textbook “Time Series Analysis: Forecasting and Control” [2].

Time series analysis is most often confused with time series forecasting, regression, and anomaly detection. Forecasting applies the analysis to the future, for example in demand planning. An ordinary regression assumes that its errors, meaning the deviations of the observations from the model, do not influence one another. A time series, by contrast, depends on today's value being linked to yesterday's and to last year's [3]. Anomaly detection can use the same decomposition to check whether the current value fits the expected pattern.

How time series analysis works

The work starts with a clean series and a simple benchmark, and the model comes only after that. The benchmark is what your planning already achieves without a model. One such benchmark is last year's value, which carries forward the figure for the same week of the previous year [4]. It captures the season but misses the trend and an Easter that moves around the calendar. The other is the moving average, which takes the mean of the last few weeks and therefore lags behind every seasonal peak. Every model has to be measured against these two benchmarks, and if it does not clearly beat them, it is not worth the effort.

StepWhat happensResult
1. Build the seriesmeasurements are aligned to a fixed interval, gaps and outliers are resolved, and holidays and promotions are added as a calendara complete series per item, customer, or machine
2. Decomposethe series is separated into trend, seasonality, and remaindera picture of how strong the seasonality is and how large the random component is
3. Set the benchmarklast year's value and the moving average are calculated on the same datathe error to beat and the margin, set before the backtest, by which the model must beat it
4. Choose the modelthe choice is between ARIMA and exponential smoothing, which gives recent values more weight. Where many factors influence the series, machine learning is added, for example gradient boosting, which combines many simple decision treesone forecast per week and horizon
5. Test on the pastin the backtest, the model forecasts past periods, knowing only what was known on the day in questionthe forecast error compared with the benchmark
6. Output the range and monitor itthe forecast appears as a band of quantiles, that is, quantities that will not be exceeded with a stated probability. Monitoring raises an alert when the actual value leaves the banda planning basis with stated uncertainty

Step 5 decides whether the result can be trusted. No forecast in the backtest may draw on an observation that still lay in the future on the forecast date [5]. Step 6 is needed because uncertainty usually grows with the horizon [6]. In the example values of our logistics series, the mean percentage error of the fleet-level forecast is 12 percent in the first week and 22 percent in the fourth.

Worked example: sales forecast for a seasonal product range

The following example is a model calculation for a fictitious company from our chocolate series and contains no client figures. A mid-sized chocolate manufacturer sells 12,000 metric tons a year and generates revenue of 95 million euros, with peaks at Christmas, Easter, and Valentine's Day.

AssumptionValue
Write-offs on seasonal stock per year570,000 euros
Revenue lost through shelf gaps per year1,140,000 euros
Contribution margin on revenue30 percent
Extra shifts and express freight per year250,000 euros
Forecast error of the last-year method over twelve weeks (example value)21.8 percent
Forecast error of the model over the same period (example value)9.4 percent
Fewer write-offs, recovered shelf gaps, lower rush costs30, 25, and 30 percent

The three levers yield 171,000 euros less in write-offs, 85,500 euros of recovered contribution margin and 75,000 euros less in rush costs, a total of 331,500 euros a year. That amount is a gross effect before implementation costs, that is, before the cost of introducing and running the model. The two forecast errors are likewise example values for the sample company rather than measured results. In a real project the backtest measures the forecast error. How far write-offs fall as a result remains an assumption even then, so the calculation needs a sensitivity check:

ScenarioWrite-offs, shelf gaps, rush costsGross effect per year
cautious20, 15, and 20 percent215,300 euros
model calculation30, 25, and 30 percent331,500 euros
favorable40, 35, and 40 percent447,700 euros

For your own rough calculation, use this formula:

Gross effect per year = write-offs × reduction + revenue lost in shelf gaps × recovered share × contribution margin on revenue + rush costs × reduction

The average error alone does not show what a forecast costs, because a forecast that is too high does not cost the same as one that is too low. In the sample company, one metric ton brings in around 7,917 euros of revenue on average across the product range. If it is missing from the shelf, the contribution margin of 2,375 euros is lost. If it is overproduced and written off after the season without residual value, up to 5,542 euros of variable costs are lost. A surplus metric ton therefore costs up to 2.3 times as much as a missing one.

That is why a good model delivers a range rather than a point value. Where planning sets the quantity within that range depends on the ratio of the two cost rates:

Target quantile = cost per missing metric ton ÷ (cost per missing metric ton + cost per surplus metric ton)

The target quantile states in how many out of 100 seasons the quantity produced should be enough. At 30 percent it is enough in 30 out of 100 seasons, and in the other 70 the company sells out. At 50 percent the company plans for the middle of the forecast.

CaseCost per missing metric tonCost per surplus metric tonTarget quantile
Surplus is written off in full2,375 euros5,542 euros30 percent
Surplus can be sold at half price2,375 euros1,583 euros60 percent
Surplus is written off, and each missing metric ton also causes around 3,167 euros of knock-on costs5,542 euros5,542 euros50 percent

None of the rows is a recommendation, because the calculation rests on four assumptions. First, price and margin are the average of the whole product range. Second, there is a single production decision before the season and no second production run. Third, the 5,542 euros are an upper limit, because part of the variable costs is never incurred for goods that are not delivered. Fourth, in the first two rows the lost contribution margin is the only damage a shelf gap causes.

Because of the fourth assumption, the first two rows leave out an item that ranks as the largest in our chocolate series, although it appears in no table: the trust of the retail chains. A supplier that fails to deliver at the seasonal peak puts its shelf space at risk. The third row turns that risk into a figure. If a missing metric ton causes around 3,167 euros of knock-on costs on top of the contribution margin, the target quantile is 50 percent even without residual value. The formula does not estimate these knock-on costs for you, but it does get sales and production talking about two cost rates.

When time series analysis pays off and when it does not

Time series analysis pays off under three conditions. The history must cover at least two full seasonal cycles. In our chocolate series, it covers three years of sales data. In addition, past special events, above all promotions and price changes, must be documented with dates. Finally, planning needs someone who wants to work with a range.

Four mistaken conclusions are easy to draw:

  • “The average error is good, so the forecast is good.” One product group can make the average look good while another misses the mark. Report the error for each product group.
  • “What holds for the total holds for the detail.” In the example values of our logistics series, the error of the fleet-level forecast for the next week is 12 percent. For individual customers it ranges from 12 to 28 percent, because small order quantities depend more heavily on chance.
  • “A model that describes the past well will also warn in time.” In our research on soft commodities, a GARCH model, a method for volatility that changes over time, passed the usual risk tests. It gave no early warning, however, because the estimated volatility followed the movement instead of running ahead of it.
  • “The forecast will see the next promotion coming.” A model knows only what is in the history. So no forecast can anticipate a promotion that a retailer schedules at short notice.

We advise against a model if the history covers fewer than two full seasonal cycles, because a single cycle is not enough to tell a season from a trend or a one-off event. We also advise against it if the product range or customer base is changing fundamentally or the model does not clearly beat the last-year method in the backtest. In that last case, planning stays with the last-year method.

You can recognize a reputable provider: they name the simple benchmark they measure their model against, show the backtest for each product group, and deliver a range instead of a single number. They also tell you before the project under which conditions they would advise against it.

Time series analysis in the data science process

In CRISP-DM, the six-phase process model for data science projects, time series analysis spans phases 3 to 5. In phase 3, data preparation, the series and the seasonal features are built. In phase 4 the model is compared with the benchmark, and in phase 5 the backtest shows whether the model's lead also pays off financially.

All six CRISP-DM phases at a glance Phase 3: data preparation Phase 4: exploratory data analysis and modelling Phase 5: model validation

Frequently asked questions about time series analysis

What is time series analysis in simple terms?

Time series analysis examines measurements in time order, such as weekly sales. It separates the series into trend, seasonality, and a remainder that cannot be explained. Trend and seasonality produce a forecast, and the remainder shows the range you need to allow for.

What is the difference between time series analysis and time series forecasting?

Time series analysis describes a series: where the trend is heading, how strong the seasonality is, and how large the random component is. Time series forecasting, often simply called forecasting, carries these components forward into the future. Every reliable forecast requires an analysis, whereas an analysis need not end in a forecast.

What data does a time series analysis need?

It needs a history at a fixed interval covering at least two full seasonal cycles, plus a calendar of special events such as promotions, price changes, and public holidays. In the worked example on this page, that means deliveries to retailers, sell-out, and the promotion calendar. Without the calendar, the model cannot tell a promotional spike from the season.

Which methods are part of time series analysis?

The classic methods are exponential smoothing and ARIMA. Where many factors influence the series, machine learning comes in, for example gradient boosting or neural networks for time series. GARCH models cover volatility that changes over time, and regime models cover shifting market conditions. The backtest against the simple benchmark decides which method fits.

What does a forecast error cost?

What a forecast error costs depends on its direction. Too much stock leads to write-offs or storage costs, while too little costs the lost contribution margin and, in retail, possibly the shelf space. So calculate the two sides separately. The ratio of the two cost rates tells you how often the planned quantity should be enough in 100 seasons.

How long does it take until a time series forecast is in operation?

The timeline depends mainly on the data. If the history is clean and comes with a promotion calendar, a backtest against your current method is ready early on. If item master data needs cleaning and promotions need recording after the fact, that work sets the schedule. After that, the forecast is integrated into the weekly planning meeting.

How does a time series analysis project begin?

It begins with a business question and the benchmark. First, the current cost of overstock and shortfalls is put into figures. Then the accuracy of your current planning is measured, for example the last-year method. Only once that error is known can you judge whether a model promises enough of a lead to justify a pilot.

Sources

  1. Rob J. Hyndman, George Athanasopoulos: Forecasting: Principles and Practice, 3rd edition, OTexts. Chapter 3, section 3.2 “Time series components”. https://otexts.com/fpp3/components.html
  2. Rob J. Hyndman, George Athanasopoulos: Forecasting: Principles and Practice, 3rd edition, OTexts. Chapter 9, section 9.12 “Further reading” and section 9.5 “Non-seasonal ARIMA models”. https://otexts.com/fpp3/arima-reading.html
  3. Rob J. Hyndman, George Athanasopoulos: Forecasting: Principles and Practice, 3rd edition, OTexts. Chapter 7, section 7.1 “The linear model”, subsection “Assumptions”. https://otexts.com/fpp3/regression-intro.html
  4. Rob J. Hyndman, George Athanasopoulos: Forecasting: Principles and Practice, 3rd edition, OTexts. Chapter 5, section 5.2 “Some simple forecasting methods”. https://otexts.com/fpp3/simple-methods.html
  5. Rob J. Hyndman, George Athanasopoulos: Forecasting: Principles and Practice, 3rd edition, OTexts. Chapter 5, section 5.10 “Time series cross-validation”. https://otexts.com/fpp3/tscv.html
  6. Rob J. Hyndman, George Athanasopoulos: Forecasting: Principles and Practice, 3rd edition, OTexts. Chapter 5, section 5.5 “Distributional forecasts and prediction intervals”. https://otexts.com/fpp3/prediction-intervals.html

Measure your planning against the simple benchmark

Your sales history and two cost rates are enough to judge whether a forecasting model can beat your current planning.

Book a free initial call