import Quandl
%matplotlib inline
data = Quandl.get('GOOG/HEL_SAMAS')
Using cached token XXX for authentication. Returning Dataframe for GOOG/HEL_SAMAS
data.Close.plot()
<matplotlib.axes.AxesSubplot at 0x1175f3610>
import statsmodels.api as sm
sm.graphics.tsa.plot_pacf(data.Close.squeeze(), lags=5)
arma_mod42 = sm.tsa.ARMA(data.Close.squeeze(), (4,2)).fit()
print arma_mod42.params
const 29.363388 ar.L1.Close 0.148839 ar.L2.Close 0.810669 ar.L3.Close -0.054313 ar.L4.Close 0.088954 ma.L1.Close 0.804977 ma.L2.Close -0.124202 dtype: float64
arma_mod42.resid.plot()
<matplotlib.axes.AxesSubplot at 0x11cccc350>
pred=arma_mod42.predict()
pred.plot()
<matplotlib.axes.AxesSubplot at 0x11ccd3690>
axis=data.Close.plot(figsize=(12, 8))
pred.plot(ax=axis, style='r--', label='predicted Close')
axis.axis(('2013-1-1', '2013-12-12', 25, 40))
axis.legend()
<matplotlib.legend.Legend at 0x11db78450>