Level 0: Foundation
★☆☆☆☆ Introductory⏱ 5 minGeneral audience. No mathematics required.Predicting from the past
An autoregressive model predicts today’s value from the last few values, like guessing tomorrow’s temperature from the past few days. A moving-average model instead remembers recent surprises, the parts that were not predicted. Many series drift, so we first look at their changes from one step to the next. If the data have a yearly rhythm, the model also looks back exactly one year.
Box and Jenkins’ ‘airline model’ for monthly airline passengers (1949–1960) is still a standard benchmark for seasonal forecasting.
- 1. An autoregressive model predicts from…
- 2. A moving-average model remembers…
- 3. A seasonal model also looks back…
Level 1: Beginner
★★☆☆☆ Basic⏱ 20 minSecondary-school mathematics: arithmetic and elementary algebra.By hand
- AR(p): y_t = c + φ₁y_(t−1) + … + φ_p y_(t−p) + e_t. It is stationary when the roots of 1 − φ₁z − … − φ_p z^p lie outside the unit circle.
- MA(q): y_t = μ + e_t + θ₁e_(t−1) + … + θ_q e_(t−q), which is always stationary. It is invertible when |θ| is below 1, so that the shocks can be recovered from the data.
- ARMA(p, q): both together. Parsimonious, because one MA term can replace a long AR.
- ARIMA(p, d, q): ARMA after d differences. The forecasts are cumulative sums of the forecast differences.
- SARIMA(p,d,q)(P,D,Q)_s: adds AR, MA and differencing at the seasonal lag s. The airline model (0,1,1)(0,1,1)₁₂ is ∇∇₁₂y_t = (1 + θB)(1 + ΘB¹²)e_t.
- Fitting: least squares for AR; conditional sum of squares or exact maximum likelihood (Kalman filter) for MA terms. Choose orders with AIC = n ln(σ̂²) + 2k or BIC.
- 1. ARIMA's 'I' stands for…
- 2. The airline model is…
- 3. An MA(1) is invertible when…
Level 2: Intermediate
★★★☆☆ Intermediate⏱ 25 minUndergraduate students and practising engineers.Fitting AR and ARMA models
Exercise 1.
- 2000 points of an AR(2) with φ = (0.6, −0.3): fit AR(0) to AR(5) by least squares and pick the order with AIC.
- 2000 points of an ARMA(1,1) with φ = 0.7 and θ = 0.4, estimated with Hannan–Rissanen: an AR(20) gives estimated shocks, then a regression on one lag of y and one lag of the shocks.
- Iterated forecasts 30 steps ahead.
Practice.
- Make the series stationary first with differencing (seasonal if needed) and transformations.
- Start simple and let AIC or BIC choose, within a small range of orders.
- Check the residuals for remaining autocorrelation with the ACF and Ljung–Box.
- Compare against naive and seasonal naive benchmarks on held-out data.
- Tools: statsmodels SARIMAX, pmdarima auto_arima, the R forecast package and StatsForecast AutoARIMA.
import numpy as np
def fit_ar(y, p):
X = np.column_stack([np.ones(len(y) - p)] + [y[p - i - 1:len(y) - i - 1] for i in range(p)])
b, *_ = np.linalg.lstsq(X, y[p:], rcond=None)
r = y[p:] - X @ b
s2 = r @ r / len(r)
return b, s2, len(r) * np.log(s2) + 2 * (p + 1)- 1. Before fitting ARMA, the series should be…
- 2. A Python function for automatic ARIMA:
- 3. Every forecasting study should include…
Level 3: Advanced
★★★★☆ Advanced⏱ 25 minGraduate level, with full derivations and proofs.Theory
Order selection. In Exercise 1, AIC for AR(0) to AR(5) was 641, 189, 15, 16, 17, 18. The drop stops at order 2, and each extra parameter then costs 2 for nothing. The estimates were φ̂ = (0.582, −0.291) and σ̂² = 1.005.
Why MA terms need tricks. The shocks e_(t−j) are not observed, so the model is nonlinear in θ. Hannan–Rissanen first fits a long AR, whose residuals approximate the shocks, and then regresses y on its own lags and on those residuals. For the ARMA(1,1) it gave φ̂ = 0.697 and θ̂ = 0.399 (true 0.7 and 0.4). Conditional sum of squares instead computes the shocks recursively for each candidate θ and minimises Σe².
Forecasts. The h-step forecast iterates the model with future shocks set to zero. For a stationary model it reverts to the mean (after 30 steps, −0.044 against a mean of −0.044). The forecast error variance grows towards the series variance, σ²(1 − φ^(2h))/(1 − φ²) for an AR(1). For ARIMA, forecasts of differences are summed back into levels, so uncertainty keeps growing.
The airline model. Differencing ∇∇₁₂ removes the trend and the season. The two MA terms make the level and the seasonal pattern evolve slowly, like exponential smoothing at two time scales. An AR approximation of a seasonal MA needs lags at 24, 36 and beyond.
- 1. AIC penalises each extra parameter by…
- 2. Hannan–Rissanen estimates shocks with…
- 3. Stationary ARMA forecasts far ahead tend to…
Level 4: Expert
★★★★★ Expert⏱ 30 minResearchers: original papers and open problems.On series that truly follow the airline model, how much better is the correctly specified SARIMA than the seasonal naive method and than AR approximations, at horizons of 1, 6 and 12 months?
History.
- G. Yule (1927) fitted autoregressions to sunspot numbers, and E. Slutsky (1927) showed that moving sums of shocks produce cycles.
- H. Wold (1938) proved that every stationary process has an MA(∞) representation.
- G. Box and G. Jenkins (1970) unified identification, estimation and diagnostics into the ARIMA methodology, including the airline model.
- E. Hannan and J. Rissanen (1982) gave the regression estimator; R. Hyndman and Y. Khandakar (2008) automated ARIMA order selection.
Exercise 2.
- 100 log-scale series from the airline model with θ = −0.4, Θ = −0.6 and shock sd 0.03 (about 3% per month).
- Train on 120 months and forecast the next 12 with four methods:
- the seasonal naive method;
- an AR (order up to 14 by AIC) on first differences;
- an AR on ∇∇₁₂y;
- the airline model, fitted by conditional sum of squares on a grid of (θ, Θ).
Seed 0, RMSE × 100 (about per cent):
| method | 1 month | 6 months | 12 months |
|---|---|---|---|
| seasonal naive | 13 | 13 | 13 |
| AR on ∇y | 3.6 | 6.0 | 7.5 |
| AR on ∇∇₁₂y | 3.2 | 5.7 | 8.7 |
| airline model | 2.7 | 4.7 | 6.8 |
- The airline model was best at every horizon, with one-step errors close to the shock sd of 3. The median estimates were θ̂ = −0.4 and Θ̂ = −0.55.
- Seasonal naive was about five times worse even one month ahead, because the level had drifted over the year it repeats.
- The AR on ∇∇₁₂y was good at one month but the worst model-based method at 12: an AR with up to 14 lags cannot represent the seasonal MA term, which reaches back 24, 36 and more months.
- Seeds 1 and 2: airline 2.9 and 3.1 at one month, 5.8 and 5.8 at 12; AR on ∇y 6.0 and 6.0 at 12; seasonal naive 11–13 throughout.
ARIMA in practice
- Automatic ARIMA (auto.arima, StatsForecast) remains a strong baseline in forecasting competitions such as M4 and M5.
- Exogenous regressors (ARIMAX, regression with ARIMA errors) add holidays, prices or weather.
- Exact likelihood through the Kalman filter handles missing values and gives proper forecast intervals.
- Limitations: linear dynamics and one series at a time; global ML models can share information across many related series.
References
- G. E. P. Box, G. M. Jenkins, G. C. Reinsel and G. M. Ljung (2015). Time Series Analysis: Forecasting and Control, 5th ed. Wiley.
- E. J. Hannan and J. Rissanen (1982). “Recursive estimation of mixed autoregressive-moving average order.” Biometrika.
- H. Akaike (1974). “A new look at the statistical model identification.” IEEE Transactions on Automatic Control.
- R. J. Hyndman and Y. Khandakar (2008). “Automatic time series forecasting: the forecast package for R.” Journal of Statistical Software.
- S. Makridakis, E. Spiliotis and V. Assimakopoulos (2020). “The M4 Competition: 100,000 time series and 61 forecasting methods.” International Journal of Forecasting.