Products & Services Solutions Academia Support User Community Company

Learn more about Econometrics Toolbox   

lbqtest - Ljung-Box Q-test

Syntax

[h,pValue,stat,cValue] = lbqtest(Series,Lags,Alpha,DoF)

Description

[h,pValue,stat,cValue] = lbqtest(Series,Lags,Alpha,DoF) performs the Ljung-Box lack-of-fit hypothesis test for model misspecification, which is based on the Q-statistic

where N = sample size, L = the number of autocorrelation lags included in the statistic, and is the squared sample autocorrelation at lag k.

Once you fit a univariate model to an observed time series, you can use the Q-statistic as a lack-of-fit test for a departure from randomness. Under the null hypothesis that the model fit is adequate, the test statistic is asymptotically chi-square distributed.

Input Arguments

Series

Vector of observations of a univariate time series for which lbqtest computes the sample Q-statistic. The last row of Series contains the most recent observation of the stochastic sequence. Typically, Series is either:

  • The sample residuals derived from fitting a model to an observed time series, or

  • The standardized residuals obtained by dividing the sample residuals by the conditional standard deviations.

Lags

Vector of positive integers indicating the lags of the sample autocorrelation function included in the Q-statistic. If specified, each lag must be less than the length of Series. If Lags = [] or is unspecified, the default is Lags = min([20, length(Series)-1]).

Alpha

Significance levels. Alpha can be a scalar applied to all lags, or a vector the same length as Lags. If Alpha = [] or is unspecified, the default is 0.05. For all elements, α, of Alpha,0 < α < 1.

DoF

Degrees of freedom. DoF can be a scalar applied to all lags, or a vector the same length as Lags. If specified, all elements of DoF must be positive integers less than the corresponding element of Lags. If DoF = [] or is unspecified, the elements of Lags serve as the default degrees of freedom for the chi-square distribution.

Output Arguments

h

Boolean decision vector. 0 indicates acceptance of the null hypothesis that the model fit is adequate (no serial correlation at the corresponding element of Lags). 1 indicates rejection of the null hypothesis. h is the same size as Lags.

pValue

Vector of probability values of the test statistics.

stat

Vector of Q-statistics for each lag in Lags.

cValue

Vector of critical values of the chi-square distribution for comparison with the corresponding element of stat.

Examples

Example 1

  1. Create a vector of 100 Gaussian random numbers:

    strm = RandStream('mt19937ar'); % reproducible
    RandStream.setDefaultStream(strm);
    Series = randn(100, 1);   % 100 Gaussian deviates ~ N(0, 1)
  2. Compute the Q-statistic for autocorrelation lags 20 and 25 at the 10 percent significance level:

    [h,P,stat,CV] = lbqtest(Series, [20 25]', 0.10);
    [h,P,stat,CV]
    
    ans =
             0    0.6185   17.5278   28.4120
             0    0.4438   25.3342   34.3816

Example 2

See Pre-Estimation Analysis.

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.

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-2009- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS