## Documentation Center |

The sample autocorrelation function (ACF) and partial autocorrelation
function (PACF) are useful qualitative tools to assess the presence
of autocorrelation at individual lags. The Ljung-Box Q-test is a more
quantitative way to test for autocorrelation at multiple lags *jointly* [1]. The null hypothesis for this
test is that the first *m* autocorrelations are jointly
zero,

The choice of *m* affects test performance.
If *N* is the length of your observed time series,
choosing
is recommended for power [2]. You can
test at multiple values of *m*. If seasonal autocorrelation
is possible, you might consider testing at larger values of *m*,
such as 10 or 15.

The Ljung-Box test statistic is given by

This is a modification of the Box-Pierce Portmanteau
"Q" statistic [3]. Under the null hypothesis, Q(*m*)
follows a
distribution.

You can use the Ljung-Box Q-test to assess autocorrelation in
any series with a constant mean. This includes residual series, which
can be tested for autocorrelation during model diagnostic checks.
If the residuals result from fitting a model with *g* parameters,
you should compare the test statistic to a
distribution with *m* – *g* degrees
of freedom. Optional input arguments to `lbqtest` let
you modify the degrees of freedom of the null distribution.

You can also test for conditional heteroscedasticity by conducting
a Ljung-Box Q-test on a squared residual series. An alternative test
for conditional heteroscedasticity is Engle's ARCH test (`archtest`).

[1] Ljung, G. and G. E. P. Box. "On a
Measure of Lack of Fit in Time Series Models." *Biometrika*.
Vol. 66, 1978, pp. 67–72.

[2] Tsay, R. S. *Analysis of Financial
Time Series*. 3rd ed. Hoboken, NJ: John Wiley & Sons,
Inc., 2010.

[3] Box, G. E. P. and D. Pierce. "Distribution
of Residual Autocorrelations in Autoregressive-Integrated Moving Average
Time Series Models." *Journal of the American Statistical
Association*. Vol. 65, 1970, pp. 1509–1526.

Was this topic helpful?