I am computing the cross-correlation function using ccf from statsmodels. It works fine except I can't see how to also plot the confidence intervals. I notice that acf seems to have much more functionality. Here is a toy example just to have something to see:
import numpy as np
import matplotlib.pyplot as plt
import statsmodels.tsa.stattools as stattools
def create(n):
x = np.zeros(n)
for i in range(1, n):
if np.random.rand() < 0.9:
if np.random.rand() < 0.5:
x[i] = x[i-1] + 1
else:
x[i] = np.random.randint(0,100)
return x
x = create(4000)
y = create(4000)
plt.plot(stattools.ccf(x, y)[:100])
This gives:
from How to plot confidence intervals for stattools ccf function?
No comments:
Post a Comment