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

折月煮酒 提交于 2021-01-29 05:40:25

问题


I'm trying to get a "fuzzy" prediction of a timeseries, using an SARIMA model

My training set is prices_train, and the model is built as follows:

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:

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

However, it seems the library has been updated since 2017, because that does not work. I've read the statsmodels manual but I haven't found much help.


回答1:


Your fit model should have a get_prediction() function that returns a prediction. Then you can call prediction.conf_int(alpha=a).




回答2:


Well I've found a way, I'll post it here in case anyone reading this in 2035 needs it:

Being h the number of predictions:

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

It returns a dataframe with the confidence interval of h predictions, indicating for each one:

  • Average
  • Mean squared error
  • Minimum
  • Maximum


来源:https://stackoverflow.com/questions/63453156/how-to-get-the-confidence-interval-of-each-prediction-on-an-arima-model

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!