SED navigation bar go to SED home page go to Dataplot home page go to NIST home page SED Home Page SED Contacts SED Projects SED Products and Publications Search SED Pages
Dataplot Vol 1 Auxiliary Chapter

LJUNG-BOX TEST

Name:
    LJUNG-BOX TEST
Type:
    Analysis Command
Purpose:
    Perform a Ljung-Box test for randomness.
Description:
    There are a large number of tests of randomness (e.g., the runs tests). Autocorrelation plots are one common method test for randomness. The Ljung-Box test is based on the autocorrelation plot. However, instead of testing randomness at each distinct lag, it tests the "overall" randomness based on a number of lags. For this reason, it is often referred to as a "portmanteau" test.

    More formally, the Ljung-Box test can be defined as follows.

    H0: The data are random.
    Ha: The data are not random.
    Test
    Statistic:
    The test statistic is:

      Q(LB) = n*(n+2)*SUM[j=1 to h][r(j)**2/(n-j)]

    where n is the sample size, r(j) is the autocorrelation at lag j, and h is the number of lags being tested.

    Significance
    Level:
    alpha
    Critical
    Region:
    The hypothesis of randomness is rejected if

      QLB > CHSPPF((1-alpha),h)

    where CHSPPF is the percent point function of the chi-square distribution.

    The Ljung-Box test is commonly used in ARIMA modeling. Note that it is applied to the residuals of a fitted ARIMA model, not the original series.

Syntax:
    LJUNG-BOX TEST <y>       <SUBSET/EXCEPT/FOR qualification>
    where <y> is the response variable being tested;
    and where the <SUBSET/EXCEPT/FOR qualification> is optional.
Examples:
    LJUNG-BOX TEST RES
    LJUNG-BOX TEST Y1 SUBSET TAG > 1
Note:
    The number of lags to test can be set by entering any of the following command (before entering the LJUNG-BOX command):

      LET LAGS = <value>
      LET LAG = <value>
      LET NUMLAG = <value>

    By default, Dataplot will use the same number of lags as the autocorrelation plot. Typically, you will want to test fewer lags. Although the choice is somewhat arbitrary, 25 is a reasonable number for many series.

Default:
    None
Synonyms:
    LJUNG TEST and LJUNG-BOX are synonyms for LJUNG-BOX TEST.
Related Commands:
    AUTOCORRELATION PLOT = Generate an autocorrelation plot.
    RUNS TEST = Perform a runs test for randomness.
    ARMA = Perform an ARIMA fit.
Reference:
    "On a Measure of a Lack of Fit in Time Series Models", G. M. Ljung and G. E. P. Box, Biometrika, 1978, 65, pp. 297-303.

    "Introduction to Time Series and Forecasting", 2nd. Ed., Peter Brockwell and Richard Davis, Springer, 2002, p. 36.

Applications:
    ARIMA Modeling
Implementation Date:
    2003/2
Program:
     
    READ NEGIZ4.DAT X1 X2 Y
    ARMA Y 2 1 0
    LET NUMLAG = 25
    LJUNG-BOX TEST RES
        
Dataplot generates the following output for the Ljung-Box test:
     
          **************************
          **  ljung-box test res  **
          **************************
    
    
                  LJUNG-BOX TEST FOR RANDOMNESS
    
    1. STATISTICS:
          NUMBER OF OBSERVATIONS      =      559
          LAG TESTED                  =       25
          LAG 1 AUTOCORRELATION       =  -0.1012441E-02
          LAG 2 AUTOCORRELATION       =   0.6160716E-02
          LAG 3 AUTOCORRELATION       =   0.5182213E-02
    
       LJUNG-BOX TEST STATISTIC       =    31.93575
    
    2. PERCENT POINTS OF THE REFERENCE CHI-SQUARE DISTRIBUTION
       (REJECT HYPOTHESIS OF RANDOMNESS IF TEST STATISTIC VALUE
       IS GREATER THAN PERCENT POINT VALUE)
       FOR LJUNG-BOX TEST STATISTIC
          0          % POINT    =          0.
          50         % POINT    =    24.33659
          75         % POINT    =    29.33885
          90         % POINT    =    34.38158
          95         % POINT    =    37.65248
          99         % POINT    =    44.31411
    
    
    3. CONCLUSION (AT THE 5% LEVEL):
          THE DATA ARE RANDOM.
          

Date created: 3/10/2003
Last updated: 4/4/2003
Please email comments on this WWW page to alan.heckert@nist.gov.