How to generate "lower" and "upper" predictions, not just "yhat"?
import statsmodels
from statsmodels.tsa.arima.model import ARIMA
assert statsmodels.__version__ == '0.12.0'
arima = ARIMA(df['value'], order=order)
model = arima.fit()
Now I can generate "yhat" predictions
yhat = model.forecast(123)
and get confidence intervals for model parameters (but not for predictions):
model.conf_int()
but how to generate yhat_lower
and yhat_upper
predictions?
In general, the
forecast
andpredict
methods only produce point predictions, while theget_forecast
andget_prediction
methods produce full results including prediction intervals.In your example, you can do:
If your data is a Pandas Series, then
yhat_conf_int
will be a DataFrame with two columns,lower <name>
andupper <name>
, where<name>
is the name of the Pandas Series.If your data is a numpy array (or Python list), then
yhat_conf_int
will be an(n_forecasts, 2)
array, where the first column is the lower part of the interval and the second column is the upper part.