Phân tích chuỗi thời gian với Python
Rob Reider
Adjunct Professor, NYU-Courant Consultant, Quantopian
Ước lượng tham số từ dữ liệu (mô phỏng)
from statsmodels.tsa.arima_model import ARMA
mod = ARMA(data, order=(1,0))
result = mod.fit()
ARMA đã bị loại bỏ, thay bằng ARIMA
from statsmodels.tsa.arima.model import ARIMA
mod = ARIMA(data, order=(1,0,0))
result = mod.fit()
Với 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 để không có khoảng tin cậyax=ax để vẽ dữ liệu và dự báo trên cùng trục
Phân tích chuỗi thời gian với Python