Search code examples
statsmodelspredictarima

statsmodels ARIMA predict is giving me predictions of the differenced signal instead of predictions of the actual signal. What mistake am I making?


The signal looks as such

original signal

The differenced signal obtained by using plot(output.diff()) looks as such

differenced signal

Next the parameters of the ARIMA model were obtained by analyzing the ACF and PACF

The model was fit in the following manner

model = ARIMA(output.values, order=(2,1,1))

model_fit = model.fit(disp=0)

When I used

model_fit.plot_predict(dynamic=False)

plt.show()

It is perfect!

result using plot_predict

but when i use plt.plot(model_fit.predict(dynamic=False))

It gives a predictions of the differenced signal

result using predict of arima


Solution

  • If you are using the model sm.tsa.ARIMA, then you can use the following:

    plt.plot(model_fit.predict(dynamic=False, typ='levels'))
    

    However, this model is deprecated and will be removed in future Statsmodels versions. For compatibility with future versions, you can use the new ARIMA model:

    from statsmodels.tsa.arima.model import ARIMA

    or

    import statsmodels.api as sm
    
    model = sm.tsa.arima.ARIMA(output.values, order=(2,1,1))
    

    This newer model will automatically produce forecasts and predictions of the actual signal, so you do not need to use typ='levels' in this case.