ARIMA, SARIMA, SARIMAX: what each letter adds
The second big family of forecasting models describes a series through its own past: through past values and past errors. The name of a model reads as a list of the mechanisms switched on, and here each of them is a separate toggle. The series is the one from the previous lessons, but a promo day has been placed inside the forecast horizon on purpose: it cannot be predicted by looking inside the series alone, and it shows why the family needed its last letter.
Red bar is the miss on the promo day. No number of lags predicts it: the reason lies outside the series, and only X brings it in.
AR โ autoregression, the number p. The model predicts today's value as a weighted sum of p past ones: ฯโ on yesterday, ฯโ on the day before. This is a literal use of the autocorrelation from the second lesson: if neighbouring days are linked, the past makes a fine predictor. The ฯ coefficients are shown under the chart.
What it means
The orders p and q are classically picked from the ACF and PACF plots, but in practice they are more often searched automatically by an information criterion such as AIC โ that is what auto_arima does. Manual selection remains a way to understand the series rather than to win accuracy.
The X part demands discipline: the values of an external feature must be known across the whole forecast horizon. A promo calendar and holidays are known; ยซtrafficยป or an exchange rate are not, and can only be plugged in via a forecast of their own, whose error passes into the main model.
The check that a model is adequate is the correlogram of its residuals. If structure remains there, the orders were chosen poorly; formally this is tested by the Ljung โ Box test, whose null hypothesis ยซthere is no autocorrelation in the residualsยป is one you actually hope not to reject.
Where it shows up
SARIMAX is the workhorse of demand forecasting: the promo calendar, holidays and price go in as features, while the weekly and yearly cycles are described by the seasonal part.
Prophet, NeuralProphet and similar libraries solve the same problem in another language โ an explicit decomposition with holidays as a separate block. The idea ยซdescribe external events with features, everything else with the structure of the seriesยป is shared with SARIMAX.
For hundreds or thousands of series at once (demand per item, say) fitting an ARIMA to each becomes expensive. Then teams move either to ETS or to global models trained across all series together.
Definitions
When the method lies (assumptions)
ARIMA is linear and assumes coefficients constant over time. A regime change โ a new pricing policy, entering a new market โ violates that, and the model has to be refitted on the new period rather than fed a longer history.
Forecast confidence intervals are computed assuming the residuals are uncorrelated with constant spread. If they are not, the intervals come out optimistically narrow and the forecast looks more confident than it is.
An external feature in X describes an association, not causation โ exactly like a regression coefficient. Promos coinciding with a rise in sales may simply mean promos were scheduled on days that were going to be good anyway.
Deep dive: the math and the mechanism (optional)
Why the letter MA is not about the mean of the last few days: MA(q) represents a series as a weighted sum of the last q random shocks. AR and MA are dual โ a stationary AR(1) unfolds into an infinite MA, and vice versa. The point of the split is economy: what takes infinitely many terms in one language takes a single coefficient in the other.
The seasonal part of SARIMA multiplies the non-seasonal one rather than adding to it: the operator looks like ฯ(B)ฮฆ(Bแต)(1โB)^d(1โBแต)^D y_t. The practical consequence is that the model also describes interactions between lags โ the link between yesterday and ยซyesterday one week agoยป, for instance, appears automatically without a parameter of its own.