Optional Python Appendix — Empirical Forecasting

Optional Python Lab 3 — Fit and Audit ARMA Errors

Compare parsimonious ARMA candidates with AICc, BIC, roots, residual ACF, and Ljung–Box evidence.

Optional Python Lab 3 — Fit and Audit ARMA Errors

Question

After deterministic structure is removed, which small ARMA model explains the remaining linear dependence without spending unsupported parameters?

The lab deliberately compares only five candidates. Exhaustive order searches can optimise noise and make the analyst's search process invisible.

Fit and audit

Py

Compare ARMA candidates

Idle

Audit sequence

  1. Root moduli above one support the enforced stationary/invertible representation; values near one signal fragile persistence.
  2. AICc is the main small-sample ranking here; BIC shows whether a stronger complexity penalty changes the decision.
  3. Residual plots ask about breaks, runs, and variance—not only average size.
  4. Ljung–Box tests remaining linear correlation up to a declared lag; a large p-value is not proof of iid Gaussian errors.
  5. The model remains provisional until rolling-origin forecast performance is compared with seasonal naive.

The true error is AR(1), but the finite sample may choose another small model. Change the seed and count selection frequencies. If the selected order changes often while forecast accuracy barely moves, report model-selection uncertainty instead of a single “correct” order.

Candidate ledger

Candidate set and why it was bounded:
AICc/BIC result:
Root boundary:
Residual pattern:
Ljung–Box lag and result:
Distribution/variance concern not tested:
Forecast comparison still required:

Two-stage boundary

The deterministic regression was estimated before ARMA fitting. This is transparent for teaching but understates joint uncertainty. The next lab estimates deterministic terms and AR errors together with SARIMAX.

Continue to Python Lab 4.

Copyright © 2026