如何获得 ARIMA 模型上每个预测的置信区间

How to get the confidence interval of each prediction on an ARIMA model

我正在尝试使用 SARIMA 模型对时间序列进行“模糊”预测

我的训练集是prices_train,模型搭建如下:

model_order = (0, 1, 1)
model_seasonal_order = (2, 1, 1, 24)
    
model = sm.tsa.statespace.SARIMAX(
    prices_train, order=model_order, 
    seasonal_order=model_seasonal_order)
model_fit = model.fit(disp=0)

我知道我可以使用此指令获得积分预测:

pred = model_fit.forecast(3) 

但我不想要点预测,我想要每个预测值的置信区间,这样我就可以得到预测值的模糊时间序列

我看过 this one 等教程,他们在其中应用了以下代码:

forecast, stderr, conf = model_fit.forecast(alpha=a)

但是,该库似乎自 2017 年以来已更新,因为那不起作用。我已经阅读了 statsmodels 手册,但没有找到太多帮助。

你的拟合模型应该有一个 get_prediction() 函数,returns 一个预测。 然后你可以调用prediction.conf_int(alpha=a).

嗯,我找到了一个方法,我会 post 放在这里,以防 2035 年阅读这篇文章的人需要它:

h预测的次数:

conf_ins = model_fit.get_forecast(h).summary_frame()

它returns一个具有h个预测的置信区间的数据帧,表示每个:

  • 平均
  • 均方误差
  • 最低
  • 最多