08 — Classical Models

ARIMA#

Classical✓ Mathematical
◆ The PatternThe workhorse of classical forecasting

ARIMA(p,d,q) combines autoregression (AR), differencing (I), and moving average (MA). The Box-Jenkins methodology uses ACF/PACF to identify orders, fits the model, then checks residuals for white noise. Auto-ARIMA automates this.

Δdyt = c + φ1Δdyt−1 + … + θ1εt−1 + … + εt
ARIMA unifies the three operations: differentiate to stationarize, AR for lag dependence, MA for shock dependence.
// Interactive — ARIMA forecast with confidence intervals
p (AR)1
d (diff)1
q (MA)1
# Python — auto ARIMA
from pmdarima import auto_arima

model = auto_arima(series, seasonal=False,
                   stepwise=True, trace=True)
print(model.summary())
forecast = model.predict(n_periods=30)
Pattern bridge: ARIMA’s model selection via AIC/BIC is the same bias-variance tradeoff as cross-validation in ML. In markets, ARIMA forecasts on price returns connect directly to moving average signals.
Performance in practice
  • The M4 competition (100K time series) showed ARIMA-based methods still competitive for short horizons (1-6 steps) — within 5% of neural methods, at 100x less compute
  • Auto-ARIMA (pmdarima) fits most univariate series in <1 second. Manual Box-Jenkins is educational but rarely needed in practice
  • For financial returns: ARIMA captures linear dependencies but misses volatility clustering. Pair with GARCH for the variance equation
  • ARIMA fails on non-stationary series with structural breaks — always test stationarity first (ADF test) and watch for regime changes
When to use this
Use when: Univariate forecasting where interpretability matters. Short-horizon forecasts (1-30 steps). As a strong baseline before trying complex models. Demand forecasting, inventory planning, economic indicators.
Skip when: You have many exogenous features (use machine learning instead). Very long horizons where uncertainty dominates. Non-stationary data with structural breaks. Multivariate dependencies are important (use VAR or neural methods).
Try it on real data
Kaggle: Airline Passengers (classic seasonal time series, 144 monthly observations) FRED: US Unemployment Rate (macroeconomic monthly series, 900+ observations)
The airline dataset is perfect for SARIMA (clear trend + seasonality). The FRED series tests ARIMA on regime-change data — notice how 2008 and 2020 break the model's assumptions.
Quick start — copy to notebook
pip install pmdarima statsmodels pandas matplotlib
# ────────────────────────────────────────
import pandas as pd, matplotlib.pyplot as plt
from pmdarima import auto_arima
from statsmodels.tsa.stattools import adfuller

df = pd.read_csv('AirPassengers.csv', parse_dates=['Month'], index_col='Month')
print(f"ADF p-value: {adfuller(df['#Passengers'])[1]:.4f}")  # test stationarity

model = auto_arima(df, seasonal=True, m=12, stepwise=True, trace=True)
fc, ci = model.predict(24, return_conf_int=True)
plt.plot(df.index, df.values, label='Observed')
plt.fill_between(pd.date_range(df.index[-1], periods=24, freq='M'), ci[:,0], ci[:,1], alpha=.2)
plt.show()
← Previous
MA Models
Open in the full reader, with the topic sidebar →