tsa.stattools.acf confint needs checking and tests #46

wesm opened this Issue Aug 25, 2011 · 2 comments


None yet

2 participants

wesm commented Aug 25, 2011

Original Launchpad bug 668759: https://bugs.launchpad.net/statsmodels/+bug/668759
Reported by: josef-pktd (joep).

the confint example in the file for tsa.stattools.acf didn't work, shape mismatch exception

I fixed the example how it looked right to me, but this needs verification, and it looks like there are no tests for it. Currently my branch only.

I didn't see that the standard errors/variance themselves are returned anywhere.

Maybe it would be better now to turn acf with statistics into a class, with lazily evaluated (cached attributes) instead of many options for various returns.


This is an old issue, but I was just looking again at tsa.stattools.acf. The confidence intervals look good to me, but there is not test coverage. I don't know where we can get the values from though.

One question is, do we want to center the confidence intervals about zero? Many programs do this, so anything outside of it is different from zero, but we center ours around the estimates, which is fine but looks a little bad. Compare these

from statsmodels.datasets.macrodata import load_pandas
from statsmodels.tsa.base.datetools import dates_from_range
import matplotlib.pyplot as plt
import numpy as np
import statsmodels.api as sm

cpi = load_pandas().data["cpi"]
dates = dates_from_range("1959q1", "2009q3")
cpi.index = dates
log_cpi = np.log(cpi)

acf, confint_acf = sm.tsa.acf(log_cpi.diff().values[1:], confint=95)
# center the confidence intervals about zero
#confint_acf -= confint_acf.mean(1)[:,None]

fig = plt.figure()
ax = fig.add_subplot(111)
ax.plot(range(41), acf, 'bo', markersize=5)
ax.vlines(range(41), 0, acf)
ax.fill_between(range(41), confint_acf[:,0], confint_acf[:,1], alpha=.25)

Closed in 8fdb37c.

@jseabold jseabold closed this Aug 19, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment