When I use the acf
function in R it plots horizontal lines that represent the confidence interval (95% by default) for the autocorrelations at various lags:
However, when I use statsmodels.graphics.tsaplots.plot_acf
in python I see a curved confidence interval based on a more sophisticated computation:
Notice that in the R version, the lags up through lag 25 are considered significant. For the same data, in the python version, only the lags up through 20 are considered significant.
What is the difference between these two methods, and which one should I trust more? Can someone explain the theory of the non-constant confidence interval computed by statsmodels.tsa.stattools.acf
?
I know I can reproduce the R horizontal lines by simply plotting something like y=[+/-]1.96 / np.sqrt(len(data))
. However, I'd like to understand the fancy curved confidence interval.
statsmodels.graphics.tsaplots.plot_acf
to plot the constant (white noise assumption) confidence interval by including the optional argumentbartlett_confint=False
, and you can get R'sacf()
to plot the nonconstant (moving average assumption) confidence interval with the argumentci.type='ma'
.