简体   繁体   中英

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

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.

Your fit model should have a get_prediction() function that returns a prediction. Then you can call 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:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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