arma_predict_plot.py 404 字节
Newer Older
1 2 3 4 5 6 7 8 9 10 11
import statsmodels.api as sm
import matplotlib.pyplot as plt
import pandas as pd

dta = sm.datasets.sunspots.load_pandas().data[['SUNACTIVITY']]
dta.index = pd.DatetimeIndex(start='1700', end='2009', freq='A')
res = sm.tsa.ARMA(dta, (3, 0)).fit(disp=0)
fig, ax = plt.subplots()
ax = dta.loc['1950':].plot(ax=ax)
res.plot_predict('1990', '2012', dynamic=True, ax=ax,
                 plot_insample=False)