What is the difference between autocorrelation in matplotlib and autocorrelation in pandas.tools.plotting?

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()
+4
source share
1 answer

pandas . .

, ( ). .

. (matplotlib pandas ) .

, matplotlib, , pandas statsmodels

dta['SUNACTIVITY_2'] = dta['SUNACTIVITY']
dta['SUNACTIVITY_2'] = (dta['SUNACTIVITY_2'] - dta['SUNACTIVITY_2'].mean()) /     (dta['SUNACTIVITY_2'].std())
plt.acorr(dta['SUNACTIVITY_2'],maxlags = len(dta['SUNACTIVITY_2']) -1, linestyle = "solid", usevlines = False, marker='')
plt.show()

:

Matplotlib

Pandas

+2

Source: https://habr.com/ru/post/1531560/


All Articles