Ljung-Box autocorrelation test
res = ljungbox(namey,p,arg1,...,argn)
* namey = a time series, a real (nx1) vector or a string equal to the name of a time series or a (nx1) real vector between quotes
* p = a scalar, the # of autocorrelations considered
* argi = arguments which can be:
- 'noplt' if the user does not want to plot the autocorrelations
- 'noprint' if the user does not want to print the results of the test
- 'meth=Box-Pierce' if the user wants to use the Box-Pierce formula instead of the Ljung-Box one
- 'size=x' if the user wants to choose the size of the autocorrelation confidence band (defaut = 0.05)
- 'styleg=x' with x between 1 and 7 if the user wants to choose the location of the legend for the graph of autocorrelations (default = 7, that is to the right of the graph)
- 'corrdf=x' whther x is the number to subtract from the entered # of autocorrelations to obtain the correct # of degrees of fredom for the test statistic (default = " of AR and MA parameters for an arma model, 0 in other cases)
- 'dropna' if the user wants to remove the NA values from the data
* res = a results tlist with:
- res('meth') = 'Ljung-Box' or 'Box-Pierce'
- res('y') = values of the input variable (residuals in the case of a tlist)
- res('acf') = autocorrelation coefficients
- res('acf_l') = low bound of the confidence interval
- res('acf_u') = upper bound of the confidence interval
- res('size') = size of the confidence band
- res('chistat') = Ljung-Box (or Box-Pierce) chi-squared
- res('chi_pvalue') = the p-value of the test
- res('chi_df') = the # of degrees of freedom
- res('namey') = name of the variable tested
- res('prests') = a boolean indicating whether the tested variable is a ts
- res('bounds') = the estimation period (if the variable was a ts)
- res('dropna') = boolean indicating if NAs have been droped
- res('nonna') = vector indicating position of non-NAs (if the option 'dropna' was active)
load(GROCERDIR+'/macros/grocer/db/bdhenderic.dat'); bounds() res1=ljungbox('delts(lm1)',6) // Example taken from function ljungbox_d. Provides the Ljung-Box test for the variation of the logrithm of M1 // in the UK and 1 to 6 autocorrelations. r=varma_d4();res2=ljungbox(r,10) // Also taken from function ljungbox_d. Example 2 provides the Ljung-Box test for the residuals of the arma estimation // provided in demo varma_d4() and 1 to 10 autocorrelations. | ![]() | ![]() |