Time Series Analysis in Python
Rob Reider
Adjunct Professor, NYU-Courant Consultant, Quantopian
To estimate parameters from data (simulated)
from statsmodels.tsa.arima_model import ARMA
mod = ARMA(data, order=(1,0))
result = mod.fit()
ARMA has been deprecated and replaced with ARIMA
from statsmodels.tsa.arima.model import ARIMA
mod = ARIMA(data, order=(1,0,0))
result = mod.fit()
For ARMA, order=(p,q)
print(result.summary())
print(result.params)
array([-0.03605989, 0.90535667])
from statsmodels.graphics.tsaplots import plot_predict
fig, ax = plt.subplots()
data.plot(ax=ax)
plot_predict(result, start='2012-09-27', end='2012-10-06', alpha=0.05, ax=ax)
plt.show()
plot_predict()
alpha=None
for no confidence intervalax=ax
to plot the data and prediction on same axesTime Series Analysis in Python