简体   繁体   English

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

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

I'm trying to get a "fuzzy" prediction of a timeseries, using an SARIMA model我正在尝试使用 SARIMA model 对时间序列进行“模糊”预测

My training set is prices_train , and the model is built as follows:我的训练集是prices_train ,model 的构建如下:

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)

I know I can get a point forecast using this instruction:我知道我可以使用以下指令获得点预测:

pred = model_fit.forecast(3) 

But I don't want a point forecast, I want a confidence interval of each predicted value so I can have a fuzzy timeseries of predicted values但我不想要点预测,我想要每个预测值的置信区间,这样我就可以获得预测值的模糊时间序列

I've seen tutorials such as this one , where they apply this code:我看过诸如this one之类的教程,他们在其中应用了以下代码:

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

However, it seems the library has been updated since 2017, because that does not work.但是,该库似乎自 2017 年以来已更新,因为那不起作用。 I've read the statsmodels manual but I haven't found much help.我已经阅读了statsmodels手册,但没有找到太多帮助。

Your fit model should have a get_prediction() function that returns a prediction.你适合的 model 应该有一个 get_prediction() function 返回一个预测。 Then you can call prediction.conf_int(alpha=a) .然后你可以调用prediction.conf_int(alpha=a)

Well I've found a way, I'll post it here in case anyone reading this in 2035 needs it:好吧,我找到了一种方法,我会在此处发布,以防 2035 年阅读此文的任何人需要它:

Being h the number of predictions:作为h预测的数量:

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

It returns a dataframe with the confidence interval of h predictions, indicating for each one:它返回一个 dataframe 和 h 个预测的置信区间,表示每个预测:

  • Average平均
  • Mean squared error均方误差
  • Minimum最低限度
  • Maximum最大

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM