Skip to content
Omnikalc

Ljung-Box test calculator

Enter the number of observations and the autocorrelations at lags 1 to 5 of a series or its residuals to get the Ljung-Box Q statistic, the Box-Pierce statistic, the degrees of freedom and the p-value.

Updated on
Your inputs

Value out of range

Value out of range

Value out of range

Value out of range

Value out of range

Value out of range

Value out of range

Results

Ljung-Box Q statistic

10.711

p-value

0.0574

Box-Pierce statistic
10.404
Degrees of freedom
5
Critical value at 5 %
11.070
White noise rejected at 5 % (1 = yes, 0 = no)
0
Approximate 95 % band for one autocorrelation
0.179

The Ljung-Box test calculator gives the Q statistic, the Box-Pierce statistic, the degrees of freedom and the p-value of a test for autocorrelation, from the number of observations and the autocorrelations at lags 1 to 5 of a series or of the residuals of a model.

How the calculation works

  • Enter the number of observations and the autocorrelations at lags 1 to 5.
  • Enter the number of parameters fitted in the model, 0 for a raw series.
  • Read Q, the p-value and whether white noise is rejected.

Example

With 120 observations and autocorrelations of 0.25, 0.12, -0.05, 0.08 and 0.03, the Ljung-Box Q is 10.711 with 5 degrees of freedom, against a critical value of 11.070. The p-value is 0.0574 and the rejection flag is 0. The Box-Pierce statistic is 10.404. A single autocorrelation outside 0.179 would be noteworthy.

Why it matters

The calculator helps analysts, students and forecasters who check the residuals of a time series model, such as ARIMA or exponential smoothing, and want to know whether any pattern remains that the model has not captured, using the autocorrelations read from a plot or from software.

Good to know

The autocorrelations must be the sample values at consecutive lags starting at lag 1, computed on the series or the residuals. Subtract the number of fitted ARMA parameters from the lags to get the degrees of freedom, and do not apply this to the residuals of a regression with lagged dependent variables. A low p-value says that some autocorrelation remains, but it does not say at which lag. A high p-value does not prove independence, especially with few observations.

The Durbin-Watson calculator tests first-order autocorrelation of regression residuals, the chi-square test calculator treats the distribution used here, the correlation significance calculator tests one correlation and the partial correlation calculator controls for other variables.

Frequently asked questions

What does the Ljung-Box test check?

The Ljung-Box test checks whether a group of autocorrelations of a time series is different from zero. The null hypothesis is that the data are independent, as in white noise. It is applied to the residuals of a fitted model: if the model is adequate, the residuals should show no autocorrelation.

What is the formula?

The statistic is Q = n × (n + 2) × Σ r_k² / (n − k), summed over the lags k = 1 to h, where r_k is the autocorrelation at lag k and n the number of observations. Under the null, Q follows a chi-square distribution with h degrees of freedom, reduced by the number of parameters fitted in an ARMA model.

How many lags should be used?

Common choices are about ln(n), or 10 lags for non-seasonal data and 2 seasons for seasonal data, up to n / 5. Too few lags may miss an autocorrelation at a longer lag, and too many lower the power of the test. This calculator uses five lags to keep the inputs simple.

How does it differ from Box-Pierce?

The Box-Pierce statistic is n × Σ r_k², the first form of the test. The Ljung-Box version weights the lags by n + 2 over n − k, and its distribution is closer to the chi-square in small samples. For large n the two give nearly the same value, and Ljung-Box is preferred.

Was this calculator helpful?

Thanks for your feedback!

Results are estimates provided for information purposes. They do not replace professional advice.