Diagnostics After Fitting a Time Series Model#

Stage 6 · 🏗️ Building & Forecasting Models · Lesson 13 of 18 · advanced

◀ Previous · Maximum Likelihood Estimation for ARMA Models (Gaussian MLE) · Next · Order Selection for Time Series Models ▶ · ↑ Section

Important

✨ AI-generated content. This page was written with the assistance of an AI language model and is provided as a learning aid. Despite careful review, it may still contain mistakes, omissions, or out-of-date information. Whether you are new to the topic, a team lead, or a senior practitioner, treat it as a starting point rather than an authoritative reference: read it critically and independently verify anything you act on (code, commands, figures, and factual claims) against official documentation and primary sources before relying on it.

The goal#

A fitted model is only as good as its residuals. If the model has captured all the structure, what remains should be white noise — patternless, uncorrelated, constant-variance. Diagnostics standardise the residuals (divide by their standard error) and then test that claim.

What to look at#

Three views, read together:

  • residual plot over time — should scatter randomly around zero, with no trend and no changing spread (heteroscedasticity);

  • residual ACF / correlogram — essentially no spikes outside the \(\pm 1.96/\sqrt{n}\) bands (spikes at seasonal lags hint at missed seasonality);

  • normality — a Q–Q plot and histogram, since valid prediction intervals lean on roughly normal errors.

statsmodels bundles these panels into results.plot_diagnostics().

The Ljung-Box test#

Eyeballing the ACF is subjective; the Ljung–Box test makes it formal. It is a portmanteau test of the residual autocorrelations jointly up to lag \(h\):

\[Q = n(n+2)\sum_{k=1}^{h} \frac{\hat{r}_k^2}{n-k},\]

compared against a \(\chi^2\) distribution. The null is no autocorrelation (white-noise residuals), so a small p-value means the model is inadequate. The degrees of freedom are reduced by the number of fitted AR / MA parameters. (acorr_ljungbox in statsmodels.)

When it fails#

Failing diagnostics are a diagnosis, not a dead end. Autocorrelation left in the residuals says the model is missing structure — add an AR or MA term, or, if the leftover spikes fall at seasonal lags, move to a seasonal model. Re-fit and re-check until the residuals look like noise.

See also

Source article Adapted (context, re-expressed) in our own words from: https://insightful-data-lab.com/2026/01/17/diagnostics-after-fitting-a-time-series-model-standardized-residuals-normality-and-autocorrelation/ (insightful-data-lab.com).

Tags: purpose: reference topic: time series level: advanced