Note: This page has been translated by MathWorks. Please click here

To view all translated materials including this page, select Japan from the country navigator on the bottom of this page.

To view all translated materials including this page, select Japan from the country navigator on the bottom of this page.

Ljung-Box Q-test for residual autocorrelation

`h = lbqtest(res)`

`h = lbqtest(res,Name,Value)`

```
[h,pValue]
= lbqtest(___)
```

```
[h,pValue,stat,cValue]
= lbqtest(___)
```

returns
a logical value (`h`

= lbqtest(`res`

)`h`

) with the rejection decision
from conducting a Ljung-Box Q-Test for
autocorrelation in the residual series `res`

.

uses
additional options specified by one or more `h`

= lbqtest(`res`

,`Name,Value`

)`Name,Value`

pair
arguments.

If any

`Name,Value`

pair argument is a vector, then all`Name,Value`

pair arguments specified must be vectors of equal length or length one.`lbqtest(res,Name,Value)`

treats each element of a vector input as a separate test, and returns a vector of rejection decisions.If any

`Name,Value`

pair argument is a row vector, then`lbqtest(res,Name,Value)`

returns a row vector.

If you obtain `res`

by fitting a model to data,
then you should reduce the degrees of freedom (the argument `dof`

)
by the number of estimated coefficients, excluding constants. For
example, if you obtain `res`

by fitting an `ARMA`

(*p*,*q*)
model, set `dof`

to *L*−*p*−*q*,
where *L* is `lags`

.

The

`lags`

argument affects the power of the test.If

*L*is too small, then the test does not detect high-order autocorrelations.If

*L*is too large, then the test loses power when a significant correlation at one lag is washed out by insignificant correlations at other lags.Box, Jenkins, and Reinsel suggest setting

`min[20,T-1]`

as the default value for`lags`

[1].Tsay cites simulation evidence that setting

`lags`

to a value approximating log(*T*) provides better power performance [5].

`lbqtest`

does not directly test for serial dependencies other than autocorrelation. However, you can use it to identify conditional heteroscedasticity (ARCH effects) by testing squared residuals [4].Engle's test assesses the significance of ARCH effects directly. For details, see

`archtest`

.

[1] Box, G. E. P., G. M. Jenkins, and G. C.
Reinsel. *Time Series Analysis: Forecasting and Control.*
3rd ed. Englewood Cliffs, NJ: Prentice Hall, 1994.

[2] Brockwell, P. J. and R. A. Davis. *Introduction
to Time Series and Forecasting*. 2nd ed. New York, NY:
Springer, 2002.

[3] Gourieroux, C. *ARCH Models and
Financial Applications.* New York: Springer-Verlag, 1997.

[4] McLeod, A. I. and W. K. Li. "Diagnostic Checking ARMA Time Series Models Using Squared-Residual Autocorrelations." Journal of Time Series Analysis. Vol. 4, 1983, pp. 269–273.

[5] Tsay, R. S. *Analysis of Financial
Time Series.* 2nd Ed. Hoboken, NJ: John Wiley & Sons,
Inc., 2005.

Was this topic helpful?