Library: | times |
See also: | acf pacf pacfplot fft invfft boxpi |
Quantlet: | boxlj | |
Description: | computes the autocorrelation function (acf) and the Box-Ljung statistics for autocorrelation in a time series. Additionally, the p-values for the statistic are computed. |
Usage: | qlb = boxlj(x {, maxlag}) | |
Input: | ||
x | T x 1 vector, time series | |
maxlag | (optional) integer, maximum lag for which the above described values are calculated, default is maxlag = 30 | |
Output: | ||
qlb | maxlag x 3 matrix, contains autocorrelation function in the first column, the Ljung-Box statistics in the second and the p-values for the statistic in the third column (see the notes). |
library("times") ; loads the quantlets from times library dax = read("dax.dat") ; monthly DAX 1979:1-2000:10 return = tdiff(log(dax)) ; generates the monthly return qlb = boxlj(return,6) ; calculates the acf, lb-stat and p-values qlb
Generates a matrix with the autocorrelation function, the Ljung-Box statistics and the corresponding p-values for the returns of the German stock index DAX Contents of qlb [1,] 0.036135 0.34474 0.55709 [2,] 0.033234 0.63746 0.72706 [3,] -0.030004 0.87697 0.83098 [4,] 0.013575 0.92619 0.92077 [5,] -0.069839 2.234 0.8159 [6,] -0.0488 2.8751 0.82434