Skip to content

Ljung–Box Test

A portmanteau hypothesis test that combines sample autocorrelations through a chosen lag to assess whether a time series or fitted-model residuals retain serial correlation across that lag set.

Version
v2 · 2026-11-14 · History
Domain-specific #
10456
Domain group
Formal Sciences
Origin domain
Experimental Design & Statistics
Subdomains
Time Series Diagnostics, Time Series Analysis → Experimental Design & Statistics
Aliases
Ljung-Box test, Ljung–Box portmanteau test, Modified Box–Pierce test

Core Idea

The Ljung–Box test asks a joint question about serial correlation. For a sequence of n observations and a chosen maximum lag h, it combines the squared sample autocorrelations at lags 1 through h using the weight n(n+2)/(n-k). Large values of the resulting Q statistic are inconsistent with a null in which the included population autocorrelations are zero, subject to the asymptotic approximation and other assumptions.

How would you explain it like I'm…

 

No faithful explanation at this level. Two of three generators judged eli5 unworkable: any kid-level picture turns the test into a yes/no pattern detector that certifies randomness or clean errors, collapsing a joint test of zero autocorrelation over a chosen lag set into a certainty, especially the misconception that a small Q proves no pattern.

Leftover-Pattern Check

Some numbers come in a line over time, like the temperature each day. When scientists make a model to predict them, the model's mistakes should not have a pattern, like a miss today hinting at a miss tomorrow. The Ljung–Box test checks the mistakes for that kind of hint, looking at many time gaps at once: one day apart, two days apart, and so on. If the score comes out big, it is a warning sign that the model missed some pattern. It doesn't say which gap is the problem, and a small score doesn't prove there's no pattern at all.

Joint Autocorrelation Test

In a time series, autocorrelation means values are related to values a certain number of steps earlier (a lag). The Ljung–Box test asks one joint question: are the autocorrelations at lags 1 through some chosen h all zero? It adds up the squared sample autocorrelations at those lags, each weighted, into a statistic called Q. A large Q is evidence against the idea that all those autocorrelations are zero. It is usually applied to the residuals of a fitted model, to check whether the model left dependence in its errors. Rejecting tells you there's leftover dependence somewhere in the tested lags, not which lag or what better model to use.

 

The Ljung–Box test is a portmanteau test of serial correlation. Given n observations and a maximum lag h, it computes Q as n(n+2) times the sum over k = 1 to h of the squared sample autocorrelation at lag k divided by (n-k). Under the null that the population autocorrelations at lags 1 through h are all zero, Q is compared with a chi-squared reference distribution, relying on an asymptotic approximation and other assumptions; large values are inconsistent with the null. The test is typically applied to residuals of a fitted time-series model, where the question is whether the model has left autocorrelation in its errors rather than whether the raw series is white noise. Estimating parameters changes the reference degrees of freedom; for an ARIMA(p,0,q) diagnostic, h-p-q is a common choice. A rejection indicates remaining dependence somewhere in the tested lag set, but does not identify which lag is responsible or what model should replace the current one.

Scope of Application

  • ARIMA residual diagnostics. Analysts test whether fitted-model residuals retain autocorrelation after accounting for estimated parameters.
  • Time-series screening. A raw series can be checked for joint departure from zero autocorrelation across a stated horizon.
  • Model comparison. Residual portmanteau evidence can reveal that one candidate leaves more serial structure than another.
  • Simulation validation. Known null and alternative processes can test finite-sample calibration for a proposed lag rule.

Clarity

A report should state the sequence tested, sample size, maximum lag, statistic, degrees of freedom, p-value, and whether parameters were estimated. 'The data are random' is too broad: the null addresses selected autocorrelations, not every form of dependence. Lag selection should precede inspection when possible, because trying many horizons and reporting one p-value changes the evidential procedure.

Manages Complexity

Many lag-specific correlations become one diagnostic, reducing multiplicity and making residual adequacy easier to summarize. The price is localization: Q does not say which lags or dynamics dominate. Plotting residual autocorrelations, examining model structure, and checking conditional variance or distributional assumptions restore information hidden by the portmanteau statistic.

Abstract Reasoning

  1. Specify whether the input is a raw series or residuals from a named fitted model.
  2. Choose a maximum lag that fits the sampling frequency and diagnostic question.
  3. Compute sample autocorrelations consistently over the effective observations.
  4. Form the Ljung–Box Q statistic rather than silently substituting the Box–Pierce formula.
  5. Select reference degrees of freedom that account for fitted parameters where required.

Knowledge Transfer

The procedure transfers across econometric, engineering, environmental, and other time series when ordering, lag, and null assumptions are meaningful. It does not transfer to unordered cross-sectional data. A generic omnibus test in another domain shares the portmanteau pattern but is not the Ljung–Box test unless the weighted autocorrelation statistic and its calibration are retained.

Relationships to Other Abstractions

Local relationship map for Ljung–Box TestParents appear above the current abstraction, mutual partners to the right, and children below. Node labels state whether each abstraction is prime or domain-specific; colors identify relation types.Ljung–Box TestDOMAINDomain-specific abstraction: Portmanteau test — is a kind ofPortmanteau testDOMAIN

Current abstraction Ljung–Box Test Domain-specific

Parents (1) — outgoing typed relations

  • Ljung–Box Test is a kind of Portmanteau test Domain-specific

    The Ljung–Box Test is the Portmanteau Test that aggregates sample autocorrelations through a chosen lag into one residual-serial-correlation statistic.

Hierarchy paths (3) — routes to 3 parentless roots

Neighborhood in Abstraction Space

Ljung–Box Test sits in a moderately populated region (49th percentile for distinctiveness): it has near-neighbors but no dense thicket of look-alikes.

Family — Statistical Hypothesis Tests & Diagnostics (9 abstractions)

Nearest neighbors

Computed from structural-signature embeddings · 2026-11-14