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? enter image description here

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]
    obs = test[t]
    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')

  • $\begingroup$ Please share the links to threads being referred in the statement "read in some other threads that this behavior is expected". $\endgroup$ Oct 17, 2022 at 17:13

2 Answers 2


It appears you are using Python's statsmodel ARIMA.

There are two options:

  1. Change order= agrument. The p, d, or q hyperparameters might be causing that result.
  2. Manually lag the predictions predictions = predictions[1:].

enter image description here

Your predicted curve (the one colored in red) is FOLLOWING your input (blue) curve. At time t, if blue goes down, then at time t+1, red will go down. You can see this behavior happening twice very clearly in the image once around t = 10 and then second time around t = 20. Also, the magnitude of change in the predicted curve is not as big/low as the input curve.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.