Entered residuals · joint lag reference

Ljung–Box Test Calculator

Enter an ordered, equal-frequency residual series, maximum lag, and fitted AR and MA orders to calculate the NIST Ljung–Box Q statistic and its asymptotic chi-square p-value. Every lag contribution stays visible, while model adequacy, residual independence, predictability and trading decisions remain explicitly outside the result.

NIST autocorrelationARMA degrees of freedomNo adequacy verdict

Enter ordered model residuals

Use residuals from one fitted model and one consistent frequency, oldest to newest. Enter the AR and MA orders represented by that model.

Entered

Accumulates autocorrelations from lag 1 through m.

AR order represented by the fitted model that produced the residuals.

MA order represented by the same fitted model.

Oldest to newest. Enter numbers without percent signs; separate with spaces, commas, semicolons or new lines. Maximum 500.

Portmanteau boundary: Ljung–Box jointly summarizes sample autocorrelations through the entered maximum lag. The p-value is an asymptotic reference, not proof of independence, model correctness, predictability or future performance.

Entered Ljung–Box arithmetic

Entered Return Statistical Diagnostics 1.0.0.

Derived
No joint-lag reference calculated yetEnter at least five non-identical residuals and valid lag/order inputs, or load the audited example.

How the Ljung–Box reference is calculated

r[k] = Σi=1n−k(e[i] − ē)(e[i+k] − ē) ÷ Σi=1n(e[i] − ē)²
Q = n(n + 2) × Σk=1m[r[k]² ÷ (n − k)]
Reference df = m − p − q

Version 1.0.0 mean-centers the complete entered residual series and uses the NIST autocorrelation denominator over all n residuals. Each lag k contributes its squared sample autocorrelation divided by n minus k.

The entered maximum lag m is reduced by entered fitted AR order p and MA order q for the asymptotic chi-square degrees of freedom. The calculator requires m minus p minus q to remain at least one.

The result is most naturally applied to residuals from a fitted time-series model. Raw returns can be entered arithmetically, but fitted-order adjustments and interpretation must still match the analysis actually performed.

Worked example from the audited fixture

The audited fixture contains 30 ordered residuals, maximum lag 5, fitted AR order 1 and fitted MA order 0.

  1. The lag 1 through 5 autocorrelations are −0.16096587, −0.43015686, −0.07597121, 0.23346264 and −0.00075898.
  2. Q = 9.41948577 with 5 − 1 − 0 = 4 reference degrees of freedom; the independently recomputed asymptotic p-value is 0.05142819. The page reports those values without a reject/retain or model-adequacy label.

Reproduce it: select “Load audited example” above. The governed engine retains full precision and rounds only the visible interface.

How to interpret the result

  • Q accumulates squared sample autocorrelations, so positive and negative lag coefficients both increase the joint statistic.
  • The audit table shows whether one lag or several lags contribute most to Q.
  • The p-value is the asymptotic chi-square survival reference for the entered Q and degrees of freedom.
  • Changing maximum lag changes both the accumulated terms and the reference degrees of freedom.
  • A reference value alone cannot verify residual independence, diagnose model structure or establish an exploitable trading pattern.

Assumptions and limits

  • Enter 5 to 500 ordered, equally spaced residuals; the maximum lag is capped at 100 and must leave at least two residual pairs.
  • All residuals must use one model, one frequency, one preprocessing rule and one oldest-to-newest order.
  • AR and MA orders are user-entered and are not inferred or validated against a fitted model.
  • The chi-square p-value is asymptotic and can be unreliable in small samples or under violated assumptions.
  • The test does not identify which model term, data issue, volatility process or structural break could explain autocorrelation.
  • No pass/fail decision, adequacy grade, independence proof, forecast, signal or recommendation is generated.

Which return diagnostic answers which question?

Distribution shape, one-lag autocorrelation, joint residual autocorrelation and multi-period variance are related but not interchangeable. The comparison below preserves each tool’s evidence requirement and prevents one statistic from being presented as a universal strategy test.

Comparison of entered evidence, questions and boundaries
DiagnosticEvidence enteredQuestion answeredMain boundary
Return Distribution AnalyzerEntered return seriesLocation, spread, percentiles, skewness and raw kurtosisDescriptive moments only.
Jarque–BeraEntered n, skewness and raw kurtosisJoint normal-reference moment statisticSmall-sample p-value withheld; no normality verdict.
Return AutocorrelationEntered return series plus one lagOne sample autocorrelation coefficientNo joint multi-lag reference.
Ljung–BoxOrdered residuals, maximum lag and fitted ordersJoint asymptotic portmanteau referenceNo residual-independence or adequacy verdict.
Observed Variance RatioEntered returns plus horizon qOverlapping multi-period variance divided by scaled one-period varianceNo corrected z test, p-value or random-walk verdict.

Frequently asked questions

  • It jointly accumulates squared sample autocorrelations from lag one through the entered maximum lag using the published n times n plus two weighting.
  • Enter ordered, equally spaced residuals from one fitted model and one preprocessing convention, oldest to newest.
  • NIST gives the asymptotic reference degrees of freedom as maximum lag minus fitted AR order minus fitted MA order.
  • Version 1.0.0 uses the complete-series mean, lagged cross-product numerator and complete-series squared-deviation denominator published by NIST.
  • It is the asymptotic chi-square survival reference for the entered Q and degrees of freedom, not the probability that the fitted model is correct.
  • The calculator does not choose it. The lag should be declared for the analysis and supported by the sample frequency, sample length and model context.
  • The arithmetic can consume them, but fitted-order adjustment and diagnostic interpretation must match the analysis actually performed.
  • No. It issues no pass/fail label, independence proof, model-adequacy grade, predictability claim, forecast, signal or recommendation.

Sources and methodology

Version 1.0.0 was locked only after the governing formulas and boundaries were checked in the cited primary or standards sources. Independent fixtures recompute the displayed statistics and reference probabilities separately from the browser adapter.

Verify the return and residual evidence

Reconcile the exact statement period, sampling frequency, timezone, realized results, spread, commission, financing, conversion and fitted-model preprocessing before deriving inputs. These browser calculations cannot certify that an entered sample is complete, stationary or representative.

XM

Review applicable statements, symbol specifications and execution terms.

Check XM terms

FBS

Confirm account-history and trading-cost conventions for your region.

Check FBS terms

FXOpen

Verify statement, charge and execution records before deriving inputs.

Check FXOpen terms

Risk and affiliate disclosure: Leveraged forex and CFD trading can result in substantial losses. These are affiliate links, so ForexMT4Indicators.com may receive compensation if you register or trade through them, at no additional cost to you. Availability and terms vary by jurisdiction and broker entity.

Disclaimer: The results from this tool are estimates for educational and informational purposes only and may differ from your broker's figures. This is not financial or investment advice. Trading forex and CFDs carries a high level of risk and can result in the loss of all your capital. Always verify calculations with your broker and trade within your risk tolerance.