Model the series by its own past
Exponential smoothing (b3) modelled the series through weighted averages of recent values. ARIMA takes a different route from the same idea: forecast each point from a linear mix of its own recent values (the AR part) and its own recent errors (the MA part), after differencing the series into something stable. Add a seasonal copy of the same machinery and you have SARIMA - the method that carries the weekly Lumen rhythm. It is powerful and it is fiddly, so Box and Jenkins gave us a disciplined recipe: make it stationary, read the orders, fit, then check the residuals.
Stationarity, and why differencing gets you there 7 min live
ARIMA assumes the series is stationary - its mean, variance, and autocorrelation do not drift over time. A trending or seasonal series is not stationary, so we difference it: replace each value with the change from the previous one. First differencing removes a trend; seasonal differencing (subtract the value 7 days ago) removes the weekly pattern. The "I" in ARIMA is that integration order, d.
LiveAR, I, and MA in plain terms3 min▶
ARIMA(p, d, q) is three ideas bolted together:
- AR(p) - autoregression. Predict today from the last p values. "Busy days tend to follow busy days" is an AR effect.
- I(d) - integration. The number of times you difference to reach stationarity. Usually 0 or 1; 2 at most.
- MA(q) - moving average. Predict today from the last q forecast errors. It lets the model correct after a shock.
Self-studyReading ACF and PACF for orders2 min read▶
Two correlograms suggest the orders on the differenced series:
- ACF (autocorrelation) - correlation of the series with its own lags. A sharp cut-off after lag q hints at an MA(q).
- PACF (partial autocorrelation) - the same, with intermediate lags removed. A sharp cut-off after lag p hints at an AR(p).
- A spike at lag 7 (and multiples) in either plot flags the seasonal orders P and Q.
These are guides, not gospel. In practice you shortlist a few orders from the plots and let an information criterion (AIC) or auto_arima pick between them.
SARIMA - a seasonal copy of the same machinery 6 min live
SARIMA adds a second set of orders that operate at the seasonal lag: (P, D, Q) with period m. For Lumen, m=7. So a SARIMA(p,d,q)(P,D,Q,7) has a non-seasonal part that handles day-to-day structure and a seasonal part that handles the week-to-week pattern - one model, two rhythms.
LiveLet auto_arima search, but keep judgement3 min▶
auto_arima (pmdarima) walks the order space and picks the combination with the best AIC, so you are not guessing every value by eye. Use it well:
- Fix what you know. Pass
m=7for the weekly period and let it search seasonal orders around it. - Bound the differencing. Set sensible
dandD(0 or 1) from the ADF test, rather than letting the search wander. - Always check residuals. A good fit leaves white-noise residuals. If the ACF of residuals still has spikes, the orders are wrong - AIC alone will not tell you that.
ARIMA vs ETS is a judgement call. On stable, structured series with clear autocorrelation, ARIMA can edge out exponential smoothing - but it asks for stationarity, order selection, and residual checks that ETS does not. FPP3's guidance: try both, backtest them, and keep whichever wins on your real horizon. Neither gets to skip the seasonal-naive bar.
Test stationarity, difference, read ACF/PACF ★ 12 min · everyone builds
Run the ADF test on the level series, difference it, confirm stationarity, then plot the correlograms to shortlist orders.
Rebuild the Lumen daily series from b1 so this notebook runs standalone.
Run adfuller on the level and on the first difference; read the p-values.
Plot plot_acf and plot_pacf on the differenced series and note where they cut off.
Fit SARIMA, forecast with an interval, beat the baseline ★ 10 min · build your own
Let auto_arima search the seasonal orders, forecast H days with a confidence interval, and score MAPE against the seasonal-naive baseline from b1. A forecast is a probability, not a promise - so we always carry the interval.
Reuse the time split from b1: last H=14 days as test, the rest as train.
Fit auto_arima(train, seasonal=True, m=7) and read the chosen orders.
Forecast H with a 95% interval, then compare MAPE to seasonal-naive - did it earn its complexity?
Watch the interval widen with the horizon. Print the confidence band for day 1 and day 14 - the day-14 band is far wider, because uncertainty compounds the further out you forecast. That is honest, not a flaw. And if SARIMA does not beat seasonal-naive on this backtest, it has not earned the extra machinery here - report that plainly and keep the simpler model, exactly as the M-competitions would predict.
Try it yourself - this week ◐ 30-45 min total
- Run the ADF test on your own series at the level and after first differencing. Record both p-values and decide d.
- Plot the ACF and PACF of the differenced series. Write down a shortlist of two or three candidate orders.
- Fit
auto_arimawithm=7, forecast your real horizon with a 95% interval, and note how much wider the band is at the last step than the first. - Score MAPE against your seasonal-naive baseline. Did SARIMA beat it? Write one honest sentence either way.
- Optional: skim FPP3 chapter 9 (ARIMA) and Box & Jenkins (1970) - the origin of the method you just used.
Sources covered (cited)
Taught from the forecasting canon and its founding text. This session covers:
Three questions before you go 🎯 ◐ 90 seconds
1 · Why must a series be stationary before fitting ARIMA?
ARIMA models the series by its own past values and errors, which only works if the statistical properties are stable over time. Differencing removes trend and seasonality to get there; the ADF test confirms it.
2 · What do the ACF and PACF plots help you choose?
A cut-off in the PACF suggests the AR order p; a cut-off in the ACF suggests the MA order q. Spikes at lag 7 flag the seasonal orders. They are guides you confirm with AIC or auto_arima.
3 · What does the seasonal part (P, D, Q, m) of SARIMA add?
SARIMA handles two rhythms: the non-seasonal (p,d,q) for day-to-day structure and the seasonal (P,D,Q) at period m for the week-to-week pattern. It still has to beat seasonal-naive on a backtest.
Builder session 4 cheat sheet · pin this
adfuller (p < 0.05 = stationary).m=7. Fix d, D from the ADF test; always check residuals.