Statsmodels: Can SARIMAX model output the confidence intervals of forecasts like ARIMAResults?

Created on 20 Jul 2018  路  4Comments  路  Source: statsmodels/statsmodels

comp-tsa

Most helpful comment

Yes, if you use the SARIMAXRresults.get_forecast method. For example:

import numpy as np
import statsmodels.api as sm

np.random.seed(1234)
x = np.random.normal(size=100)
mod = sm.tsa.SARIMAX(x)
res = mod.fit()
fcast = res.get_forecast(10)
print('Forecast:')
print(fcast.predicted_mean)
print('Confidence intervals:')
print(fcast.conf_int())

yields

Forecast:
[ 0.10982 -0.02356  0.00505 -0.00108  0.00023 -0.00005  0.00001 -0.
  0.      -0.     ]
Confidence intervals:
[[-1.79673  2.01636]
 [-1.97349  1.92637]
 [-1.94685  1.95695]
 [-1.95308  1.95091]
 [-1.95176  1.95223]
 [-1.95205  1.95195]
 [-1.95198  1.95201]
 [-1.952    1.95199]
 [-1.952    1.952  ]
 [-1.952    1.952  ]]

All 4 comments

Yes, if you use the SARIMAXRresults.get_forecast method. For example:

import numpy as np
import statsmodels.api as sm

np.random.seed(1234)
x = np.random.normal(size=100)
mod = sm.tsa.SARIMAX(x)
res = mod.fit()
fcast = res.get_forecast(10)
print('Forecast:')
print(fcast.predicted_mean)
print('Confidence intervals:')
print(fcast.conf_int())

yields

Forecast:
[ 0.10982 -0.02356  0.00505 -0.00108  0.00023 -0.00005  0.00001 -0.
  0.      -0.     ]
Confidence intervals:
[[-1.79673  2.01636]
 [-1.97349  1.92637]
 [-1.94685  1.95695]
 [-1.95308  1.95091]
 [-1.95176  1.95223]
 [-1.95205  1.95195]
 [-1.95198  1.95201]
 [-1.952    1.95199]
 [-1.952    1.952  ]
 [-1.952    1.952  ]]

thanks a lot!

The resulting model of your example above is (1,0,0), which requires the previous value to predict the next one. By making multiple predictions the model uses predicted values to predict the next one. Why does the confidence interval not grow when predicting further out ? I've tried with predicting 100 values out, but the confidence interval does not grow. Is that expected behavior or am I missing a setting?

Thanks

This is expected behavior. In stationary models, the forecasts will converge to a fixed value with fixed error bands, corresponding to the unconditional distribution of the model.

On the other hand, if you have a non-stationary model (such as order=(1, 1, 0)), then the confidence intervals will grow without bound over time.

Was this page helpful?
0 / 5 - 0 ratings