【问题标题】:unusual forecast values for ARIMA with d>0 but with autoarima its workingd>0 的 ARIMA 的异常预测值,但 autoarima 的工作正常
【发布时间】:2020-08-28 09:07:16
【问题描述】:

所以我试图获得 5 个 arima 模型(预测未来 1 到 5 天)。如果我使用 d>0 或 q>0,则使用 statsmodels arima 类无法正常工作。 使用自动 arima 它的工作 (pmdarima)。

例如(统计模型)

p,d,q = 1, 1, 0

models = []
for dayidx in range(0,5):
    models.append(ARIMA(exog=X_train[dayidx], endog=y_train[dayidx],order=(p,d,q)).fit())

models[0].forecast(exog=X_test[0],steps=157)[0]

如果我使用 p>0、d>0 和 q=0 的预测,我得到的不是预期的目标值(只是增加的值,比如 x2-x10 更高)。如果我使用预测 p>0, d=0, q=0 我会得到可取的值。如果我为 q 使用任何值,我会得到以下错误,这告诉我数据是非平稳的,为什么我使用 d>0 在我使用 q>0 的情况下它应该工作但它确实......

The computed initial AR coefficients are not stationary
You should induce stationarity, choose a different model order, or you can
pass your own start_params.

这里是 pmarima 模型的代码

auto_arima = {'adf': [], 'kpss': []}
stattests = ('adf','kpss')
for stattest in stattests:
    print(stattest)
    for dayidx in range(0,5):
        auto_arima[stattest].append(pm.auto_arima(y=y_train[dayidx], exogenous=X_train[dayidx],
                             stepwise=True,
                             suppress_warnings=True, 
                             error_action="ignore",
                             test=stattest,
                             start_p=0,
                             start_d=0,
                             start_q=0,
                             max_p=6,
                             max_d=3,
                             max_q=3,
                             max_order=None, 
                             trace=False))
    print('done')

使用 Auto Arima (pmdarima) 工作正常(我从 d -> d>0 得到值)

Training with adf
(1, 0, 1)
(4, 0, 1)
(1, 0, 1)
(2, 0, 2)
(2, 0, 0)
Training with kpss
(1, 1, 2)
(1, 1, 2)
(2, 1, 1)
(1, 1, 2)
(2, 1, 1)

这些是用于训练 arima 模型的参数 (pmarima)。所以q应该>0

有人知道为什么来自 statsmodels 的 ARIMA 对我不起作用,而来自 pmarima 的 autoarima 对我有用吗?

【问题讨论】:

    标签: python statsmodels pmdarima


    【解决方案1】:

    pmdarima 使用 Statsmodels 类 sm.tsa.SARIMAX 而不是类 sm.tsa.ARIMA 类。

    目前,建议对所有 ARIMA 模型使用 sm.tsa.SARIMAX 类,因为 sm.tsa.ARIMA 类不再接收功能更新,并将在下一个版本 (v0.12) 中弃用。

    (还有一个新类sm.tsa.arima.ARIMA,它将是下一个Statsmodels 版本中的推荐版本,因为它包含sm.tsa.SARIMAX 的所有功能,但还包括拟合模型的替代方法。)

    【讨论】:

      猜你喜欢
      • 2020-04-18
      • 2018-08-20
      • 2019-05-20
      • 1970-01-01
      • 2021-12-28
      • 1970-01-01
      • 1970-01-01
      • 2018-04-15
      • 1970-01-01
      相关资源
      最近更新 更多