Time Series Forecasting: Decomposition, ETS and ARIMA

After reading this you will know how to split a time series into trend, season and noise, how ETS and ARIMA build forecasts, and how to trust the one that predicted best out of sample instead of the one that fit best in hindsight.

What the lab does, with one example

Give the lab a column of numbers ordered in time and it does four things. It splits the series into a trend, a repeating seasonal pattern and a leftover remainder. It fits an exponential-smoothing model (ETS). It fits a seasonal ARIMA model. Then it forecasts ahead and, most usefully, it scores every candidate against simple baselines using rolling-origin cross-validation, so the headline forecast is the model that actually predicted the recent past.

The demo data is the classic monthly airline passenger series, 144 observations from January 1949 to December 1960. It starts at 112 thousand and ends at 432. Two things jump out: a clear upward trend, and a yearly cycle that peaks every July or August and dips every November. The cycle also grows with the level: the 1949 summer bump is about 40 passengers, the 1960 bump is about 200. That growing swing is the signal that decides whether the lab works on the original scale or on logs.

When to use it, and when not

Use the lab when you have a single series measured at regular intervals (monthly sales, daily visits, quarterly revenue) and you want a short forecast with honest uncertainty. It is built for one series at a time with a fixed spacing between points.

Do not use it when the gaps between observations are irregular, when the next value depends mostly on outside drivers you could measure (price, weather, a campaign), or when you have fewer than about two full seasonal cycles. With monthly data that means at least 24 points, and more is much better. If your data has no time order at all, you want the Descriptive Statistics Calculator instead. To inspect the autocorrelation structure directly, use the Autocorrelation Calculator.

Decomposition: trend, season, remainder

The lab uses an STL-style decomposition. It estimates a smooth trend with loess, subtracts it, averages what is left within each season position to get the seasonal shape, and iterates with robustness weights so a single spike lands in the remainder rather than bending the trend. The additive model is

y_t = T_t + S_t + R_t

where y_t is the observed value, T_t the trend, S_t the seasonal component and R_t the remainder. Two numbers summarise how much structure each component holds, the Wang-Smith-Hyndman strengths:

F_s = 1 - \frac{\text{Var}(R_t)}{\text{Var}(S_t + R_t)}

and the same form with T_t for trend strength F_t. Both run from 0 to 1. On the airline data the trend strength is above 0.97 and the seasonal strength above 0.9: almost all the variation is trend plus season, with little left over. A flat, noisy series would score near 0 on both.

Seasonal strength drives an automatic choice: when it exceeds 0.64 the ARIMA search applies a seasonal difference. That threshold is a convention, not a law of nature, but it separates series where copying last season helps from ones where it does not.

ETS and ARIMA: two ways to forecast

ETS (error, trend, season) writes the forecast as a weighted average of past values where the weights fade geometrically. The simplest form updates a level:

\ell_t = \alpha y_t + (1 - \alpha)\ell_{t-1}

Here \ell_t is the current level and \alpha between 0 and 1 sets how fast old data is forgotten. At \alpha = 0.3 the most recent point gets weight 0.3, the one before 0.21, the one before that 0.147, and so on. The full lab adds a trend term (optionally damped, so long forecasts flatten) and a seasonal term that can be additive or multiplicative. It picks the variant with the lowest AICc.

ARIMA takes a different route. It differences the series until it looks stationary (a constant mean and variance), then models the differenced values as a mix of past values and past errors:

\phi(B)(1-B)^d y_t = \theta(B)\varepsilon_t

where B is the backshift operator, d the number of differences, \phi and \theta the autoregressive and moving-average polynomials, and \varepsilon_t white-noise errors. A seasonal version repeats the same idea at the seasonal lag. The lab screens orders up to (p,q) \le (3,3) and seasonal (P,Q) \le (1,1) and refits the best few properly.

ETS and ARIMA overlap but are not the same. ETS thinks in terms of level, trend and season directly. ARIMA thinks in terms of correlations between a value and its recent past. On many series they land within a few percent of each other, which is why the lab also offers their simple average.

Exponential smoothing weights the most recent observation by the smoothing parameter alpha and each older observation by alpha times (1 minus alpha) to the power of its age. At alpha = 0.3 the weights are 0.3, 0.21, 0.147, 0.103 for the last four points. A larger alpha reacts faster to recent changes but is noisier; a smaller alpha is smoother but slower to turn.

Rolling-origin cross-validation picks the winner

The lowest AICc tells you which model fits the data you already have. It does not tell you which will forecast next month. To answer that, the lab uses rolling-origin cross-validation. It cuts the series at several points, fits each model on the data up to the cut, forecasts the steps after it, and compares those forecasts to what actually happened. With five folds you get five out-of-sample tests per model.

Four error scores summarise the folds. Mean absolute error (MAE) and root mean squared error (RMSE) are in the units of the data. MAPE is a percentage. The most useful for comparison is MASE, which divides your error by the error of the seasonal-naive baseline:

\text{MASE} = \frac{\text{mean}|y_t - \hat{y}_t|}{\text{mean}|y_t - y_{t-m}|}

where m is the season length. MASE below 1 means you beat copying last season. MASE above 1 means the naive rule would have served you better. A model can win on AICc and still post a MASE above 1, which is exactly the trap cross-validation catches.

Reproducing the airline demo

Load the demo data and let every setting stay on auto. Here is what the lab reports and why.

  1. It detects monthly spacing from the YYYY-MM dates and sets the season length to 12.
  2. The seasonal swing grows with the level, so the auto scale picks a log transform. On the log scale the swing is roughly constant, which lets an additive model work.
  3. Decomposition returns trend strength above 0.97 and seasonal strength above 0.9. The remainder is small and looks like noise.
  4. ETS settles on a model with a seasonal term and, depending on the fit, a trend. ARIMA keeps a seasonal difference but finds the seasonally differenced log series already stationary, so it lands on an AR(2) with drift and a seasonal MA term, (2,0,0)(0,1,1)[12], a close cousin of the classic airline model (0,1,1)(0,1,1)[12].
  5. Cross-validation over four origins (a fifth would leave too little training data) scores both below the baselines, with MASE around 0.4 to 0.5. The better of the two, or their combination, becomes the headline forecast.

The horizon defaults to two seasons, so 24 months. The forecast continues the upward trend and repeats the summer peak, with an 80% interval that widens the further out it goes.

The history rises with a yearly peak each summer. Past the marker at month 143 the line is the forecast, which extends the trend and repeats the seasonal shape.

Reading and interpreting the results

Start with the cross-validation table, not the fitted forecast. Find the model with the lowest MASE and check it is below 1. If the best model still sits above 1, no model here beat the seasonal-naive rule, and you should forecast by copying last season and move on.

Then look at the prediction interval. The 95% band means that if the model is right about the noise, the true value should fall inside about 19 times out of 20. The band widens with the horizon because errors compound. A band that barely widens over 24 steps is a warning that the intervals are too narrow.

Finally check the residual diagnostic. A Ljung-Box p-value under 0.05 says the residuals still carry pattern the model missed, so the point forecast may be fine but the intervals understate the risk.

Report MAE or RMSE in your data's units for a stakeholder, but compare models with MASE. RMSE punishes large misses more than MAE, so a model can win on MAE and lose on RMSE when it occasionally misses badly. Naming both tells you whether your errors are steady or spiky.

Common mistakes

Trusting AICc alone
AICc ranks in-sample fit. Two models with different differencing are not even comparable on AICc. Let cross-validation decide.
Forecasting far past the data
A 24-month forecast from 144 points is reasonable. A 60-month forecast is mostly the model's assumptions, not your data. Damped trends help but do not create information you do not have.
Ignoring the growing swing
On the airline data an additive model on the original scale forces one constant seasonal size across a fourfold change in level. The log transform fixes this. If your intervals look wrong, check the scale.
Too few observations
Seasonal ARIMA and seasonal ETS need several full cycles to estimate the seasonal shape. With 18 monthly points the season is guesswork.
Structural breaks
A policy change or a one-off shock breaks the assumption that the past predicts the future. Spot large remainders with the Outlier Detector before trusting the fit.

Related tools

The lab pairs naturally with the Autocorrelation Calculator to see the lag structure ARIMA models, and with the Descriptive Statistics Calculator for the summary of any single component. If you suspect a few points are distorting the trend, run the Outlier Detector on the remainder. For relationships between two series rather than one over time, the Covariance Calculator is the right starting point.

Frequently asked questions

How many data points do I need to forecast?

For a non-seasonal series, a few dozen points give a usable trend. For a seasonal series you want at least two full cycles just to estimate the season, and four or more to estimate it well. With monthly data that means 24 points minimum and 48 or more preferred.

Why did the lab choose a log scale?

When the seasonal swing and the noise grow in proportion to the level, a log transform turns that multiplicative pattern into an additive one that the models handle directly. On the airline data the summer bump grows from about 40 to about 200 as the level rises, which is the classic signal for logs.

What is the difference between ETS and ARIMA?

ETS models the series as a level, trend and season updated by smoothing weights. ARIMA models it through correlations between a value and its recent past and errors. They often forecast within a few percent of each other; when they disagree, cross-validation picks the winner, and the combination sometimes beats both.

What does a MASE of 0.5 mean?

Your average absolute error is half the average absolute error of copying the value from one season ago. Below 1 beats that naive rule; above 1 means the naive rule would have been better and the model is not earning its complexity.

Why do my prediction intervals look too narrow?

Check the Ljung-Box p-value. Below 0.05 means the residuals still hold structure, so the model underestimates its own uncertainty. Intervals also assume the noise size stays roughly constant on the modelling scale, so a missed variance change narrows them too.