Seasonal ARIMA (SARIMA)
Python · R · time-series forecasting
Model
A seasonal ARIMA (SARIMA) extends Box–Jenkins ARIMA with seasonal terms, written SARIMA(p, d, q)(P, D, Q)[s]: regular and seasonal AR/MA orders, regular differencing to remove trend, and seasonal differencing to remove seasonality, at season length . The canonical case is the "airline model" SARIMA(0,1,1)(0,1,1)[12] — the one Box & Jenkins fit to the airline series — with one regular difference, one seasonal difference, and an MA(1) × seasonal-MA(1), no AR terms.
| Symbol | Part | Meaning |
|---|---|---|
| AR / seasonal AR | dependence on the last lags / last seasonal lags | |
| differencing / seasonal | removes trend; removes the seasonal pattern | |
| MA / seasonal MA | dependence on the last shocks / last seasonal shocks | |
| season length | 12 for monthly data |
The airline model is .
Frequentist Box–Jenkins vs Bayesian structural
Two routes are compared. The frequentist Box–Jenkins workflow (identify → estimate by maximum likelihood via the Kalman filter → diagnose residuals) is run in statsmodels and R's forecast, with automatic order selection (auto_arima / auto.arima, the Hyndman–Khandakar stepwise AIC search). The Bayesian route is an interpretable structural regression — a linear trend + monthly seasonal dummies + AR(1) errors — fit by NUTS, giving full posterior-predictive forecast distributions. The two differ in how they handle seasonality: SARIMA uses seasonal differencing (, stochastic seasonality that can drift), the structural model uses fixed monthly effects (deterministic seasonality) — both legitimate, and they forecast similarly when the seasonal shape is stable.
Notebooks
Five examples span the range of ARIMA behaviour — fixed-period seasonality, variable-period cyclicality, a near-deterministic trend-plus-season, a barely-forecastable business cycle, and a structural break — building the ARIMA → changepoint → regime-switching ladder.
Example 1 — AirPassengers (multiplicative seasonality). Monthly airline passengers, 1949–1960 (Box & Jenkins): a clear upward trend and multiplicative seasonality (swings grow with the level), the textbook case for SARIMA on the log scale. Stationarity tests (ADF / KPSS, opposite nulls) call for a regular and a seasonal difference; both selectors pick the airline model SARIMA(0,1,1)(0,1,1)[12], residuals pass Ljung–Box, and the held-out 2 years forecast to MAPE ≈ 8–9%. A judgement caveat surfaces: left to choose itself, auto_arima picks , leaving the trend in and degrading the forecast — automated selectors still need the differencing pinned by the unit-root tests.
Example 2 — Sunspots (cyclicality, not seasonality). Annual sunspot counts, 1700–2008: the famous ~11-year solar cycle is cyclicality — a variable, unknown period (~9–13 yr, wandering), not a fixed seasonal one. There is no seasonal differencing; the series is stationary () and a plain AR(p) generates the pseudo-cycle through complex-conjugate roots whose angle sets the period. The ACF is a damped sine wave (vs. sharp seasonal spikes), all three engines select ~AR(9) and recover a ~10–11-year cycle (Yule's 1927 AR(2) on this very series was the original demonstration), and the forecast damps toward the mean within a cycle or two — a stochastic cycle is only predictable a short way out. The Bayesian AR adds a genuine posterior distribution over the cycle length, read from the complex roots of each draw.
Example 3 — Mauna Loa CO₂ (near-deterministic trend + season). Monthly atmospheric CO₂, 1958–2001 (the Keeling curve): an accelerating upward trend plus a very regular additive annual cycle (~7 ppm, constant amplitude — so no log transform). STL splits it into a smooth trend, an almost perfectly repeating cycle, and a tiny remainder; auto_arima picks a parsimonious SARIMA, and the held-out 5 years forecast to MAPE ≈ 0.2% — among the most forecastable series anywhere, the opposite extreme from the damping sunspot cycle.
Example 4 — US GNP growth (the business cycle). Quarterly real GNP growth, 1951–1984 (Hamilton 1989): the macroeconomic business cycle is cyclicality with no fixed period — recessions arrive irregularly. Growth is already stationary (a difference of log GNP, so ) with only weak autocorrelation, so it is close to unforecastable: the ARMA's out-of-sample RMSE essentially ties predicting the mean and the forecast reverts within ~2 quarters — the honest empirical basis for "nobody forecasts GDP growth," the opposite extreme from CO₂. The Bayesian AR(1) puts (a growth-shock half-life under a quarter). Crucially, a linear ARMA is symmetric, but real recessions are sharper than expansions — which is exactly what the Markov-switching AR adds on this very series; ARMA is the linear benchmark it improves on.
Example 5 — Nile river flow (structural break / intervention). Annual Nile flow at Aswan, 1871–1970, which drops abruptly around 1899 (the old Aswan dam). The lesson: an ignored level shift masquerades as non-stationarity — differencing "fixes" it mechanically, but the right model adds a step-dummy regressor (Box–Tiao intervention analysis: regression with ARIMA errors), giving a parsimonious stationary AR(1) with a clean estimate of the break ( units) and a lower AIC than a differenced ARIMA. The Bayesian version goes further — a changepoint model that estimates the break year itself as a parameter , whose posterior concentrates tightly on 1899 without being told. A changepoint is "Markov-switching with a single, absorbing switch" — completing the ARIMA → changepoint → Markov-switching ladder.
Together they bridge from seasonality/cyclicality through structural breaks toward the regime-switching and GARCH / stochastic-volatility work, where the variance (or the regime) itself becomes the moving part. Each example is cross-checked across statsmodels / pmdarima, PyMC, and R forecast.
References
- Box, G. E. P. & Jenkins, G. M. (1970). Time Series Analysis: Forecasting and Control. Holden-Day. — the Box–Jenkins methodology, the AirPassengers series, and the airline model
- Hyndman, R. J. & Khandakar, Y. (2008). Automatic time series forecasting: the forecast package for R. Journal of Statistical Software 27(3), 1–22. — the
auto.arima/auto_arimastepwise order selection - Yule, G. U. (1927). On a method of investigating periodicities in disturbed series, with special reference to Wolfer's sunspot numbers. Philosophical Transactions of the Royal Society A 226, 267–298. — the AR model of the sunspot cycle
- Box, G. E. P. & Tiao, G. C. (1975). Intervention analysis with applications to economic and environmental problems. Journal of the American Statistical Association 70(349), 70–79. — the step-dummy / intervention model behind the Nile analysis
- Cobb, G. W. (1978). The problem of the Nile: conditional solution to a changepoint problem. Biometrika 65(2), 243–251. — the Nile flow changepoint at 1899
- Hamilton, J. D. (1989). A new approach to the economic analysis of nonstationary time series and the business cycle. Econometrica 57(2), 357–384. — the US GNP-growth data and the business-cycle motivation for regime switching
Downloads
airpassengers.csv Monthly international airline passengers, 1949–1960 (Box & Jenkins) sunspots.csv Annual sunspot counts, 1700–2008 (Wolf / SIDC numbers) co2.csv Monthly atmospheric CO₂ at Mauna Loa, 1958–2001 (the Keeling curve) hamilton_gnp.csv Quarterly US real GNP growth, 1951–1984 (Hamilton 1989) nile.csv Annual Nile river flow at Aswan, 1871–1970 (level shift ~1899)