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.

The test is often used on residuals after fitting a time-series model. There the question is not whether the original series is white noise, but whether the fitted model has left autocorrelation in its errors. Parameter estimation affects reference degrees of freedom; for an ARIMA(p,0,q) diagnostic, h-p-q is a common adjustment. Rejection signals remaining dependence somewhere in the tested lag set, not which lag causes it or what model should replace the current one.

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.

Structural Signature

Sig role-phrases:

  • Ordered observations or residuals — Supply the sequence whose serial dependence is questioned. It is required input. Counterfactual: Unordered observations do not define lag autocorrelation.
  • Sample size n — Sets scaling and finite-sample correction. It is required parameter. Counterfactual: Using inconsistent effective sample sizes changes the statistic.
  • Maximum lag h — Defines the joint autocorrelation horizon under review. It is required design choice. Counterfactual: Different h values test different alternatives and degrees of freedom.
  • Sample autocorrelations — Measure serial relation at each included lag. It is required statistics. Counterfactual: Raw residual magnitude cannot substitute for lag correlation.
  • Portmanteau statistic Q — Aggregates lag evidence into one nonnegative test statistic. It is defining transformation. Counterfactual: Separate per-lag tests are not the Ljung–Box procedure.
  • Reference distribution and degrees of freedom — Convert Q to a p-value or rejection rule under the null approximation. It is required inference rule. Counterfactual: Ignoring parameter fitting can make the residual diagnostic miscalibrated.

What It Is Not

  • The test is not a separate hypothesis test at every lag; it aggregates evidence across the selected set.
  • Failure to reject does not prove independence, normality, correct variance, or a correct model outside the tested lags.
  • A significant result does not identify a causal mechanism or establish that every included autocorrelation is nonzero.
  • The Ljung–Box statistic is not identical to the simpler Box–Pierce statistic, even though both are portmanteau tests.
  • Closest near-miss. The Box–Pierce test uses n times the sum of squared autocorrelations; Ljung–Box uses n(n+2)/(n-k) weighting to improve the null approximation.

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.
  6. Interpret rejection as residual serial-correlation evidence and follow with localized diagnostics and model revision.

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.

Examples

Canonical

After fitting an ARIMA(p,0,q) model, an analyst computes residual autocorrelations through lag h, forms Q, and compares it with a chi-squared reference using an h-p-q adjustment where appropriate.

Mapped back: adjustment → estimated ARMA parameters; lags → 1 through h; sequence → model residuals; statistic → Ljung–Box Q.

Applied / In Practice

A significant Q says at least some included serial correlation remains; it does not identify a causal mechanism or prove every lag is nonzero.

Mapped back: evidence → joint rejection; invalid conclusion → all lags or a causal model; valid conclusion → residual autocorrelation remains.

Structural Tensions

T1 — Short Lag Horizon versus Broad Lag Horizon. Small h targets local dependence with fewer degrees of freedom, while large h can detect broader structure but dilute or distort power.

Diagnostic: Why is the selected horizon relevant to the fitted model and sampling frequency?

T2 — Simple Asymptotic Calibration versus Fitted-Model And Finite-Sample Effects. The chi-squared rule is convenient, but estimation and small samples alter its accuracy.

Diagnostic: Have parameter estimation and sample size been reflected in calibration?

Structural–Framed Character

Ljung–Box Test is strongly structural with analyst-selected scope. Its statistic and null calibration are mathematical, while the series, lag horizon, model-fitting adjustment, and significance policy frame the inference. Those choices can materially change the answer and must be visible.

Structural Core vs. Domain Accent

The skeleton is an omnibus statistic that aggregates several correlated diagnostics. Time-series analysis supplies ordered observations, lags, autocorrelation, residual models, and chi-squared calibration. Removing those yields a general joint test rather than Ljung–Box.

This entry is a kind of Portmanteau test.

  • Approved root. No reviewed parent currently entails this finite-sample-weighted portmanteau autocorrelation statistic.

  • Related — hypothesis test, autocorrelation, and residual diagnostic. These are necessary analytic neighbors without an asserted parent edge.

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

Not to Be Confused With

  • Box–Pierce test. Tell: Uses n times the sum of squared autocorrelations and lacks the Ljung–Box lag-specific finite-sample weight.
  • Durbin–Watson test. Tell: Targets a more specific regression-residual serial-correlation setting and statistic.
  • Breusch–Godfrey test. Tell: Uses an auxiliary regression and can test specified higher-order serial correlation in regression residuals.
  • Individual ACF confidence bands. Tell: Assess lags separately and do not implement the portmanteau joint statistic.

References

  • Frozen Wikipedia discovery revision: https://en.wikipedia.org/wiki/Ljung%E2%80%93Box_test (revision 1322912568).