Algorithm selectorARIMA

[Time Series]

ARIMA.

AutoRegressive Integrated Moving Average for time series forecasting.

Sales forecastingStock analysisWeather prediction

SPEC SHEET

FamilyTime Series
InterpretabilityHigh
Training speedFast
Data neededMedium
ComplexityMedium

C — How it actually works

Explain a series by its own past: tomorrow ≈ weighted recent values (AR), plus weighted recent forecast errors (MA), after differencing away the trend (I). Small, transparent, statistically principled - and with confidence intervals that mean something. For one well-behaved series, it is still a formidable baseline.

D — The math

ARIMA(p,d,q): after d differences, y_t = c + Σφᵢy_{t−i} + Σθⱼε_{t−j} + ε_t. SARIMA adds seasonal (P,D,Q,s) terms. Fit by maximum likelihood; select orders via ACF/PACF plots or AIC search.

Training

O(n·iterations) - seconds for typical series

Inference

O(horizon)

E — When NOT to use it

  • Many related series with shared patterns (use pooled/global models: boosting, DeepAR-style)
  • Strong exogenous drivers dominate (promotions, weather) - use ARIMAX or feature-based ML
  • Multiple overlapping seasonalities and holiday effects (Prophet or ML handles these more gracefully)
  • Regime changes that invalidate stationarity assumptions

F — Tuning that matters

  • Difference only until stationary (ADF/KPSS tests) - over-differencing adds noise
  • Read ACF (suggests q) and PACF (suggests p) before brute-forcing pmdarima.auto_arima
  • Check residuals: they should be white noise (Ljung-Box) or the model is missing structure
  • Always backtest with rolling-origin evaluation, never one random split

G — Production pitfalls

  • Fitting on non-stationary data and admiring an R² that is really just the trend
  • One 80/20 chronological split as "validation" - use rolling windows
  • Forecasting 52 weeks ahead from a model with a 4-week memory
  • Ignoring the widening confidence intervals that are honestly telling you "I do not know"

H — Minimal starting point

PYTHON
from statsmodels.tsa.statespace.sarimax import SARIMAX

model = SARIMAX(y, order=(1, 1, 1), seasonal_order=(1, 1, 1, 12))
res = model.fit(disp=False)
fcast = res.get_forecast(steps=12)
mean, ci = fcast.predicted_mean, fcast.conf_int()

I — The interview question

Why difference a series before modelling it?

AR/MA theory assumes stationarity - stable mean and autocovariance. Trends and random walks violate it, producing spurious correlations and unstable coefficients. Differencing (y_t − y_{t−1}) removes stochastic trends so the ARMA machinery models genuine short-run dynamics.

J — In the wild

Grid operators forecast next-day electricity load with SARIMA variants: strong daily/weekly cycles, decades of methodological trust, and interpretable coefficients that regulators and dispatch engineers can interrogate.

K — Consider instead