SafeZone AI Learn
Learn/ Forecasting/ Time Series & Forecasting · lesson 3 of 7

ARIMA and Box–Jenkins

AR and MA processes built from white noise, their ACF/PACF fingerprints simulated live until you can read them on sight, the backshift algebra that unifies the family — and what auto-ARIMA automated away.

Exponential smoothing models components — level, trend, season. ARIMA models dependence itself: it asks what linear machine, fed white noise, would produce a series with exactly the correlations yours has. That inversion of viewpoint — from “what is the series made of” to “what process generates these correlations” — is the deepest idea in classical time series, and it comes with the field’s best diagnostic skill: reading ACF/PACF fingerprints. This lesson trains that skill on a simulator where you control the truth.

Two atoms: AR and MA

Autoregression — the present is a linear function of the past plus a shock:

AR(p):yt=ϕ1yt1++ϕpytp+εt.\text{AR}(p): \quad y_t = \phi_1 y_{t-1} + \cdots + \phi_p y_{t-p} + \varepsilon_t .

Memory is recursive: a shock at time tt echoes forever, decaying geometrically (for AR(1), ρk=ϕ1k\rho_k = \phi_1^k exactly). Stationarity demands the echo fade — for AR(1), ϕ1<1|\phi_1| < 1; in general the roots of the AR polynomial must lie outside the unit circle, and at ϕ1=1\phi_1 = 1 the process is the random walk, the unit root of lesson 1.

Moving average — the present is a blend of recent shocks:

MA(q):yt=εt+θ1εt1++θqεtq.\text{MA}(q): \quad y_t = \varepsilon_t + \theta_1 \varepsilon_{t-1} + \cdots + \theta_q \varepsilon_{t-q} .

Memory is finite: after qq steps a shock is gone completely, so the ACF cuts off dead at lag qq — the sharpest fingerprint in the field.

The PACF (partial autocorrelation — correlation of yty_t with ytky_{t-k} after projecting out lags 1..k11..k{-}1, the Frisch–Waugh idea from the Projections lesson working a time-series job) mirrors the pattern. The identification table earning its keep for seventy years:

ACFPACF
AR(pp)decays graduallycuts off after lag pp
MA(qq)cuts off after lag qqdecays gradually
ARMAdecaysdecays

Drill the pure cases first. AR(1) with φ₁ = 0.6: ACF stair-steps down geometrically (readout confirms ACF(1) ≈ φ₁ = 0.6 — the theory, holding in the noise), PACF has ONE bar then nothing. Flip to MA(1) (φ₁ = 0, θ₁ = 0.6): the fingerprints swap — ACF one bar, PACF decays. Two-bar cutoffs for the order-2 versions. Then the instructive extremes: φ₁ = 0.95 gives the slow-decay ACF of near-nonstationarity (one step from the random walk — the readout’s root monitor is watching); φ₁ = −0.6 oscillates; and φ₁ = 0.5 with φ₂ = 0.55 crosses the unit circle — the series visibly explodes and the readout calls it. Ten minutes here and you will read real ACF plots the way the old-timers do.

The backshift algebra, and the “I”

With the backshift operator Byt=yt1B y_t = y_{t-1}, the whole family compresses:

ϕ(B)AR poly(1B)dyt  =  θ(B)MA polyεt— ARIMA(p,d,q),\underbrace{\phi(B)}_{\text{AR poly}} \, (1 - B)^d \, y_t \;=\; \underbrace{\theta(B)}_{\text{MA poly}} \, \varepsilon_t \qquad \text{— ARIMA}(p, d, q),

where (1B)d(1-B)^d is lesson 1’s differencing, promoted to a model component: “integrated” of order dd. The algebra is not just notation — it is how the equivalences come out: SES is ARIMA(0,1,1); Holt’s linear method is ARIMA(0,2,2); a seasonal factor (1Bm)(1 - B^m) gives SARIMA, whose (1,1,1)(1,1,1)12(1,1,1)(1,1,1)_{12} workhorse fits most monthly business series. The two classical pillars are one algebra wearing two interfaces.

Box–Jenkins, then and now

The classical loop: identify (dd by unit-root tests and ACF decay; p,qp, q from the fingerprints) → estimate (MLE — the Probability module’s engine, with the Gaussian likelihood built by the state-space form) → check (residual ACF white? Ljung–Box test aggregate the lags?) → iterate. What auto.arima automated is the identify step, by AIC search over (p,d,q)(p, d, q) — and honesty requires saying it usually wins: the human fingerprint reader’s residual value is (a) sanity-checking the search on weird series, (b) reading residual diagnostics, which no AIC search does for you, and (c) knowing that near-cutoff cases are genuinely ambiguous (an AR(1) with φ = 0.5 at n = 100 is statistically hard to tell from ARMA(1,1) — the fingerprints blur, and forecast accuracy barely cares).

Boundaries, honestly drawn: ARIMA is linear with constant variance — volatility clustering needs GARCH, regime switches need state-space (next lesson), and nonlinear dependence needs the neural lesson. And like ETS, an ARIMA fitted to one series learns nothing from the thousand sibling series next to it — the limitation the global-model revolution attacks.

import numpy as np
from statsmodels.tsa.arima.model import ARIMA
from statsmodels.tsa.arima_process import ArmaProcess
from statsmodels.stats.diagnostic import acorr_ljungbox

rng = np.random.default_rng(1)
y = ArmaProcess(ar=[1, -0.6], ma=[1]).generate_sample(400, distrvs=rng.standard_normal)

fit = ARIMA(y, order=(1, 0, 0)).fit()
print(fit.params[1])                                   # ≈ 0.6: MLE recovers φ
print(acorr_ljungbox(fit.resid, lags=[10]).lb_pvalue)  # large p: residuals white ✓

wrong = ARIMA(y, order=(0, 0, 1)).fit()                # deliberately misspecified
print(acorr_ljungbox(wrong.resid, lags=[10]).lb_pvalue)  # small p: it shows

Exercises

Work these before the next lesson

  1. Derive the AR(1) ACF: from stationarity, show ρk=ϕ1k\rho_k = \phi_1^k, and Var(y)=σ2/(1ϕ12)(y) = \sigma^2/(1-\phi_1^2). What happens to the variance as ϕ11\phi_1 \to 1, and how does that connect to the random walk’s nonstationarity?
    Solution

    Worked solutions are part of Premiumunlock all of them for £5/month →

  2. 5 more exercises — each with a worked solution — are part of Premium. Unlock everything for £5/month →

References

  • G. Box & G. Jenkins, Time Series Analysis: Forecasting and Control, 1970 — the methodology’s namesake.
  • R. Hyndman & G. Athanasopoulos, Forecasting: Principles and Practice, ch. 9.
  • R. Hyndman & Y. Khandakar, “Automatic Time Series Forecasting: The forecast Package for R”, 2008 — how auto.arima actually searches.