How autocorrelation calculation in matplotlib differs from other libraries like pandas.tools.plotting, sm.graphics.tsa.plot_acf, etc.
From the code below, you can see that the automatic correlation values returned by these two libraries are different, for example, matplotlib returns all automatic correlation values greater than zero and pandas.tools.plotting returns some autocorrelation values (except for confidence interval, negative x axis).
import matplotlib.pyplot as plt
import statsmodels.api as sm
import pandas as pd
from pandas.tools.plotting import autocorrelation_plot
dta = sm.datasets.sunspots.load_pandas().data
dta.index = pd.Index(sm.tsa.datetools.dates_from_range('1700', '2008'))
del dta["YEAR"]
plt.acorr(dta['SUNACTIVITY'],maxlags = len(dta['SUNACTIVITY']) -1, linestyle = "solid", usevlines = False, marker='')
plt.show()
autocorrelation_plot(dta['SUNACTIVITY'])
plt.show()
source
share