Skip to Main Content Skip to Search
Product Documentation

lbqtest - Ljung-Box Q-test for residual autocorrelation

Syntax

[h,pValue,stat,cValue] = lbqtest(res)
[h,pValue,stat,cValue] = lbqtest(res,Name,Value)

Description

[h,pValue,stat,cValue] = lbqtest(res) and [h,pValue,stat,cValue] = lbqtest(res,Name,Value) perform the Ljung-Box lack-of-fit hypothesis test for model misspecification.

The "portmanteau" test of Ljung and Box assesses the null hypothesis that a series of residuals exhibits no autocorrelation for a fixed number of lags L, against the alternative that some autocorrelation coefficient ρ(k), k = 1, ..., L, is nonzero. The test statistic is

where T is the sample size, L is the number of autocorrelation lags, and ρ(k) is the sample autocorrelation at lag k. Under the null, the asymptotic distribution of Q is chi-square with L degrees of freedom.

Input Arguments

res

Vector of residuals for which the test statistic is computed. The last element corresponds to the most recent observation. Typically, res contains (standardized) residuals obtained by fitting a model to an observed time series.

Name-Value Pair Arguments

Specify optional comma-separated pairs of Name,Value arguments, where Name is the argument name and Value is the corresponding value. Name must appear inside single quotes (' '). You can specify several name and value pair arguments in any order as Name1,Value1,...,NameN,ValueN.

'lags'

Scalar or vector of positive integers indicating the number of lags L used to compute the test statistic. Each element must be less than length(res−1).

Default: min[20,T-1]

'alpha'

Scalar or vector of nominal significance levels for the tests. Elements must be greater than zero and less than one.

Default: 0.05

'dof'

Scalar or vector of degree-of-freedom parameters for the asymptotic chi-square distributions of the test statistics. Elements must be positive integers less than the corresponding element of lags.

Default: value of lags

Output Arguments

h

Vector of Boolean decisions for the tests, with length equal to the number of tests. Values of h equal to 1 indicate rejection of the null of no autocorrelation in favor of the alternative. Values of h equal to 0 indicate a failure to reject the null.

pValue

Vector of p-values of the test statistics, with length equal to the number of tests.

stat

Vector of test statistics, with length equal to the number of tests.

cValue

Vector of critical values for the tests, determined by alpha, with length equal to the number of tests.

Examples

Test exchange rates for autocorrelation, ARCH effects:

load Data_MarkPound
returns = price2ret(Data);
residuals = returns-mean(returns);
h1 = lbqtest(residuals)
h2 = lbqtest(residuals.^2)

Algorithms

References

[1] Box, G.E.P., G.M. Jenkins, and G.C. Reinsel. Time Series Analysis: Forecasting and Control. 3rd ed. Upper Saddle River, NJ: Prentice-Hall, 1994.

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

[3] 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.

[4] Tsay,R.S. Analysis of Financial Time Series. Hoboken, NJ: John Wiley & Sons, Inc., 2005.

See Also

archtest | autocorr

  


Free Interactive Computational Finance CD

View demos and recorded presentations led by industry experts.

Now On Demand
Network with industry peers and learn the latest applications of the leading software product for computational finance.

 © 1984-2012- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS