statsmodels ARIMA predict 给了我对差分信号的预测,而不是对实际信号的预测.我犯了什么错误? [英] statsmodels ARIMA predict is giving me predictions of the differenced signal instead of predictions of the actual signal. What mistake am I making?

查看:21
本文介绍了statsmodels ARIMA predict 给了我对差分信号的预测,而不是对实际信号的预测.我犯了什么错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

信号看起来是这样

原始信号

使用plot(output.diff())得到的差分信号是这样的

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

差分信号

接下来通过分析ACF和PACF得到ARIMA模型的参数

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

模型拟合如下

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

model_fit = model.fit(disp=0)

当我使用

model_fit.plot_predict(dynamic=False)

plt.show()

太完美了!

使用 plot_predict 的结果

但是当我使用 plt.plot(model_fit.predict(dynamic=False))

它给出了差分信号的预测

It gives a predictions of the differenced signal

使用 arima 预测的结果

推荐答案

如果你使用的是sm.tsa.ARIMA模型,那么你可以使用以下:

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

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

但是,此模型已弃用,并将在未来的 Statsmodels 版本中删除.为了与未来版本兼容,您可以使用新的 ARIMA 模型:

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:

从 statsmodels.tsa.arima.model 导入 ARIMA

import statsmodels.api as sm

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

这个较新的模型将自动生成实际信号的预测和预测,因此在这种情况下您不需要使用 typ='levels'.

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.

这篇关于statsmodels ARIMA predict 给了我对差分信号的预测,而不是对实际信号的预测.我犯了什么错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆