amberwaves
amberwaves

Reputation: 35

In-sample prediction interval for ARIMA in Python

I am using the statsmodels ARIMA to build models and give estimates. predict() can be used to give the in-sample model estimates/results. forecast() can be used to give out-of-sample estimates and prediction intervals. I need the prediction intervals for the in-sample model results. Is there any operation that can be used? Can forecast() be called for in-sample?

Upvotes: 1

Views: 1860

Answers (1)

cfulton
cfulton

Reputation: 3195

If possible, you should switch to using the SARIMAX model, which has more features and will be better supported going forwards (the ARIMA model will be deprecated in the next release). The results object will then have methods called get_prediction and get_forecast that will allow you to create a new results object that is extended with your new values.

The syntax for getting prediction intervals is a little different, but it supports intervals both in-sample and out-of-sample.

from statsmodels.tsa.api import SARIMAX
model = SARIMAX(timeseries, order=(1, 0, 6))
results = model.fit()

pred = results.get_prediction(start=..., end=...)
print(pred.predicted_mean)        # prediction
print(pred.conf_int(alpha=0.05))  # confidence interval

fcast = results.get_forecast(steps=...)
print(fcast.predicted_mean)        # forecast
print(fcast.conf_int(alpha=0.05))  # confidence interval

Upvotes: 1

Related Questions