How to forecast time series using AutoReg

一个人想着一个人 提交于 2021-01-27 18:54:47

问题


I'm trying to build old school model using only auto regression algorithm. I found out that there's an implementation of it in statsmodel package. I've read the documentation, and as I understand it should work as ARIMA. So, here's my code:

import statsmodels.api as sm
model = sm.tsa.AutoReg(df_train.beer, 12).fit()

And when I want to predict new values, I'm trying to follow the documentation:

y_pred = model.predict(start=df_test.index.min(), end=df_test.index.max())
# or
y_pred = model.predict(start=100, end=1000)

Both returns a list of NaNs.

Also, when I type model.predict(0, df_train.size - 1) it predicts real values, but model.predict(0, df_train.size) predicts NaNs list.

Am I doing something wrong?


P.S. I know there's ARIMA, ARMA or SARIMAX algorithms, that can be used as basic auto regression. But I need exactly AutoReg.


回答1:


You can use this code for forecasting

model = sm.tsa.AutoReg(df_train.beer, 12).fit()
y_pred = model.model.predict(model.params, start=df_test.index.min(), end=df_test.index.max())


来源:https://stackoverflow.com/questions/63428622/how-to-forecast-time-series-using-autoreg

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!