ARIMA forecast for timeseries is one step ahead
I'm trying to forecast timeseries with ARIMA. As you can see from the plot, the forecast is one step ahead of the expected values. I read in some other threads that this behavior is expected but how? How can I synchronize?
The code I used:
history = [x for x in train]
predictions = list()
for t in range(len(test)):
model = ARIMA(history,order=(2, 2, 1))
model_fit = model.fit(disp=0)
output = model_fit.forecast(alpha=0.05)
yhat = output[0]
predictions.append(yhat)
obs = test[t]
history.append(obs)
print('predicted=%f, expected=%f' % (yhat, obs))
rmse = sqrt(mean_squared_error(test, predictions))
print('Test RMSE: %.3f' % rmse)
# plot
plt.plot(test, color='blue')
plt.plot(predictions, color='red')
plt.show()
Topic forecasting time-series python
Category Data Science