# lbqtest

Ljung-Box Q-test for residual autocorrelation

## Syntax

## Description

returns the rejection decision from conducting a Ljung-Box Q-test for autocorrelation in the input
residual series.`h`

= lbqtest(`res`

)

returns a table containing variables for the test results, statistics, and settings
from conducting a Ljung-Box Q-test for residual autocorrelation in the last variable
of the input table or timetable. To select a different variable to test, use the
`StatTbl`

= lbqtest(`Tbl`

)`DataVariable`

name-value argument.

`[___] = lbqtest(___,`

specifies options using one or more name-value arguments in
addition to any of the input argument combinations in previous syntaxes.
`Name=Value`

)`lbqtest`

returns the output argument combination for the
corresponding input arguments.

Some options control the number of tests to conduct. The following conditions
apply when `lbqtest`

conducts multiple tests:

For example,
```
lbqtest(Tbl,DataVariable="ResidualGDP",Alpha=0.025,Lags=[1
4])
```

conducts two tests, at a level of significance of 0.025, for the
presence of residual autocorrelation in the variable `ResidualGDP`

of the table `Tbl`

. The first test includes `1`

lag in the test statistic, and the second test includes `4`

lags.

## Examples

## Input Arguments

## Output Arguments

## More About

## Tips

If you obtain the input residual series by fitting a model to data, reduce the degrees of
freedom `DoF`

by the number of estimated coefficients, excluding
constants. For example, if you obtain the input residuals by fitting an
ARMA(*p*,*q*) model, set
`DoF`

=*L*−*p*−*q*,
where *L* is the value of `Lags`

.

## Algorithms

The value of the

`Lags`

argument*L*affects the power of the test.If

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

*L*is too large, 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 the default setting

`Lags`

=`min[20,T-1]`

[1].Tsay cites simulation evidence showing better test power performance when

*L*is approximately`log(T)`

[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`

.

## References

[1] Box, George E. P., Gwilym M. Jenkins, and Gregory 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.

## Version History

**Introduced before R2006a**