Strange and very low results in Ljung-Box test

acf-pacfautocorrelationstatsmodelstime serieswhite noise

I have been reading some posts about the Ljung-Box test and I am applying it to some of my databases. However, I am not really understanding the outputs, I think I am doing something wrong. I have a time series data every 5 minutes and I want to check if it is White Noise. The data has 800 rows and it is the following (mostly all 1):

[1  1  1  1  1  1  1  1  1  1  1  1  1  5  4  4  1  1  1  1  1  1  1  2
  1 10  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1
  2  2  4  1  3  1  1  1  1  1  2  1  1  1  1  1  1  1  2  3  2  1  1  2
  1  1  1  2  2  2  1  1  1  1  1  1  1  1  1  2  1  3  1  1  1  1  1  1
  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  7 11  7  1  1  1  1  1...1]

I am also plotting the ACF of statsmodels with 40 lags. The outputs of the function acf are:

[ 1.          0.40168385  0.17665485 -0.00746597  0.00272706 -0.02031781
  0.00265903  0.01285206  0.01281804  0.00511375  0.066442    0.0459539
  0.07660102 -0.02058992 -0.01688757 -0.00580984  0.00271113 -0.0024364
 -0.00247042 -0.00506119 -0.02043578 -0.00768598  0.01784761  0.05872178
  0.04875562  0.08707303  0.01299028  0.06153473 -0.0100886  -0.01523614
 -0.02038367 -0.0127474  -0.01278142  0.00763866  0.0101614   0.06381938
  0.06634212  0.08420544  0.01258211  0.01510486  0.00740056]

thus I can see that they are very close to 0 starting from lag 3, what gives me the idea of it being white noise. However, when I run the Ljung-Box test of statsmodels, it returns me the following data:

       lb_stat     lb_pvalue     bp_stat     bp_pvalue
1   144.570070  2.666584e-33  144.085478  3.403318e-33
2   172.562972  3.376189e-38  171.953272  4.579536e-38
3   172.613028  3.471591e-37  172.003048  4.701366e-37
4   172.619714  2.865290e-36  172.009689  3.873593e-36
5   172.991262  1.677989e-35  172.378331  2.267774e-35
6   172.997633  1.040093e-34  172.384645  1.403245e-34
7   173.146633  5.446860e-34  172.532147  7.341165e-34
8   173.295013  2.628478e-33  172.678869  3.539256e-33
9   173.318656  1.255253e-32  172.702221  1.687471e-32
10  177.314414  8.455177e-33  176.644405  1.164428e-32
           ...           ...         ...           ...
31  202.825613  3.860873e-27  201.502716  6.810909e-27
32  202.977258  9.384704e-27  201.648600  1.654383e-26
33  203.031484  2.341230e-26  201.700706  4.117698e-26
34  203.127555  5.651189e-26  201.792912  9.923617e-26
35  206.921511  2.839503e-26  205.430023  5.319358e-26
36  211.026126  1.249621e-26  209.360364  2.515537e-26
37  217.646477  1.909240e-27  215.692230  4.339157e-27
38  217.794461  4.405961e-27  215.833601  9.997658e-27
39  218.007986  9.768113e-27  216.037345  2.215969e-26
40  218.059303  2.287945e-26  216.086253  5.172516e-26

Since the pvalues are so low, I reject the null hypothesis, what gives the result of it not being white noise while the ACF plot was indicating the opposite. Am I interpreting it correctly?

Thank you very much!!

Best Answer

I can see that they are very close to 0 starting from lag 3, what gives me the idea of it being white noise

White noise should have close to zero autocorrelations for all (nonzero) lags, not only from the third lag on. Perhaps your time series is better approximated by an MA(2) process of the form $$ x_t=\mu_t+\varepsilon_t+\theta_1\varepsilon_{t-1}+\theta_2\varepsilon_{t-2} $$ with $\varepsilon_t$ being white noise. For such a process, you would see nonzero autocorrelation at lags 1 and 2 and zero autocorrelation beyond that. MA(2) is of course not white noise, and the Ljung-Box test is likely picking that up.

Related Question