Quant Memo
Core

Ljung-Box and Portmanteau Tests

A statistical test that checks a whole batch of autocorrelations at once, rather than one lag at a time, to answer a single question: do these residuals still contain leftover predictable pattern, or do they look like genuine white noise?

Prerequisites: Autocorrelation and Serial Correlation

After fitting an ARIMA or GARCH model, the standard next question is: did the model actually capture everything predictable, or is there leftover structure still sitting in the residuals? Checking one autocorrelation at a time — is lag 1 significant, is lag 2 significant, is lag 3 — is both tedious and statistically sloppy, since testing many lags one by one inflates the chance of a false alarm purely from repeated testing. The Ljung-Box test (a type of "portmanteau" test, meaning it bundles many checks into one suitcase) answers the whole question in a single statistic: are the first mm lags of autocorrelation, taken together, distinguishable from what pure noise would produce?

An analogy: checking a shuffled deck all at once

Imagine you shuffled a deck and want to know if it's truly random, or if some sneaky pattern survived the shuffle — say, every 5th card is suspiciously often a face card. Checking card 1 alone tells you almost nothing; checking every single position one at a time and flagging anything unusual will eventually flag something purely by chance, even in a perfectly shuffled deck, just because you looked so many times. A portmanteau test is like running one combined check across the first several dozen positions at once and asking "taken together, does this whole pattern look more organized than pure chance would produce?" — a single yes/no answer that doesn't fall into the trap of over-testing.

The test, one piece at a time

Given residuals ε^t\hat\varepsilon_t from a fitted model and their estimated autocorrelations ρ^k\hat\rho_k at lags k=1,,mk=1,\ldots,m, the Ljung-Box statistic is:

Q=n(n+2)k=1mρ^k2nk,Q = n(n+2) \sum_{k=1}^{m} \frac{\hat\rho_k^2}{n-k},

where nn is the sample size and mm is the number of lags being checked together (a common choice is mlnnm \approx \ln n or a fixed round number like 10 or 20). In plain English: each lag's squared autocorrelation is weighted slightly more heavily for lower kk (via the nkn-k denominator, which accounts for fewer usable observations at higher lags) and summed up — QQ is large when several lags show non-trivial autocorrelation together, even if no single lag would look alarming on its own. Under the null hypothesis that the true residuals are white noise, QQ follows a chi-squared distribution with mpm - p degrees of freedom (where pp is the number of fitted model parameters, subtracted because fitting a model already uses up some of the residuals' natural randomness). A large QQ, exceeding the chi-squared critical value, rejects the null — the residuals still contain detectable leftover autocorrelation, meaning the model missed something.

Worked example 1: passing residual diagnostics

An analyst fits an AR(1) model to a return series (n=250n=250, so p=1p=1 parameter) and checks the first m=10m=10 lags of residual autocorrelation. The individual ρ^k\hat\rho_k all come out small, as expected from a well-fit model, giving k=110ρ^k2/(nk)0.00015\sum_{k=1}^{10} \hat\rho_k^2/(n-k) \approx 0.00015. With n(n+2)=250×252=63,000n(n+2) = 250\times252 = 63{,}000, the statistic is Q63,000×0.000159.5Q \approx 63{,}000 \times 0.00015 \approx 9.5. Against a chi-squared distribution with 101=910-1=9 degrees of freedom (critical value at 5%: about 16.9), Q=9.5Q=9.5 falls well below the threshold — the residuals look like white noise, and the AR(1) model has captured the linear structure adequately.

Worked example 2: catching a misspecified model

A different fund fits a simple AR(1) to a series that actually has meaningful weekly seasonality (lag-5 autocorrelation from a trading-week pattern), so the residuals still carry a moderate ρ^50.18\hat\rho_5 \approx 0.18 even though lags 1-4 look clean. With n=500n=500, this single lag contributes 0.182/(5005)0.00006540.18^2/(500-5) \approx 0.0000654 to the sum, and combined with small contributions from the other 9 lags, QQ comes out around 22.4 against the same 9 degrees of freedom (critical value 16.9) — the test correctly flags the model as inadequate, even though no individual lag other than 5 looked dramatic, because the combined signature across all 10 lags together crossed the chi-squared threshold.

+bound-bound lag 5
No single lag beyond lag 5 looks alarming, but the Ljung-Box statistic sums the squared autocorrelation across all ten lags together, correctly detecting the combined leftover pattern that individual checks would miss.
crit=16.9 Q=9.5 well-fit model Q=22.4 misspecified model
The well-fit model's Q-statistic sits comfortably below the chi-squared critical value; the misspecified model's exceeds it, correctly signaling remaining structure in the residuals.

What this means in practice

Ljung-Box is the standard last step in fitting any ARIMA, SARIMA, or GARCH model: after fitting, always check the residuals (or squared residuals, for volatility models) with a portmanteau test before trusting the model's forecasts. A significant result means going back and adding more lags, a seasonal term, or a different specification — not proceeding as if the model were complete.

The Ljung-Box test bundles the autocorrelations across several lags into a single chi-squared statistic, testing whether they're jointly distinguishable from white noise — it catches leftover structure spread thinly across many lags that checking each lag individually, with its own inflated false-alarm risk, would likely miss.

A model can pass a Ljung-Box test on its raw residuals while still badly misspecifying volatility — the test as usually applied checks linear autocorrelation in the levels, not in the squared residuals, so a GARCH-type pattern (volatility clustering, with no linear autocorrelation in returns themselves) sails right through undetected. Always additionally run the test on squared (or absolute) residuals when checking for missed volatility structure, not just on the residuals themselves.

Related concepts

Practice in interviews

Further reading

  • Ljung & Box, On a Measure of Lack of Fit in Time Series Models, Biometrika 1978
ShareTwitterLinkedIn