The Python module statsmodels
contains functions for ACF and PACF. Below is an example from the docs with a plot that shows the (zero-centered) confidence interval on the autocorrelation coefficients. The ACF doc states that
95 % confidence intervals are returned where the standard deviation is computed according to Bartlett’s formula.
I tried to chase down this formula and found some slides (p.6) seeming to state that variance of the estimated autocorrelation approaches $\frac{1+\phi^2}{1-\phi^2}$ as the lag increses, but I don't understand the reasoning behind it.
Is there an intuitive explanation for why the CI widens as lag k increases on the ACF plot but not on the PACF?
In my novice understanding, the value of the ACF at k is equivalent to the coefficient you would obtain from univariate regression of the zero-th term as a function of the k-th term. The value of the PACF at k is like the kth coefficient you would get from a multivariate regression using all terms from 1 to k. Is that right?
If so, I don't understand why the CI on ACF widens (other than each increase in k diminishes n by one) and why this effect isn't the same for the PACF.
(On the other hand, it looks like in the R implementation the width of the CI of the ACF might be constant-- Does that plot just use the limit of Bartlett's formula for all values of k?)
import pandas as pd
import matplotlib.pyplot as plt
import statsmodels.api as sm
dta = sm.datasets.sunspots.load_pandas().data
dta.index = pd.Index(sm.tsa.datetools.dates_from_range('1700', '2008'))
del dta["YEAR"]
sm.graphics.tsa.plot_acf(dta.values.squeeze(), lags=40)
sm.graphics.tsa.plot_pacf(dta.values.squeeze(), lags=40)
plt.show()