statsmodels.tsa.arima_model.ARIMAResults.predict¶
-
ARIMAResults.
predict
(start=None, end=None, exog=None, typ='linear', dynamic=False)[source]¶ ARIMA model in-sample and out-of-sample prediction
- Parameters
- start
int
,str
,or
datetime
Zero-indexed observation number at which to start forecasting, ie., the first forecast is start. Can also be a date string to parse or a datetime type.
- end
int
,str
,or
datetime
Zero-indexed observation number at which to end forecasting, ie., the first forecast is start. Can also be a date string to parse or a datetime type. However, if the dates index does not have a fixed frequency, end must be an integer index if you want out of sample prediction.
- exogarray_like,
optional
If the model is an ARMAX and out-of-sample forecasting is requested, exog must be given. exog must be aligned so that exog[0] is used to produce the first out-of-sample forecast. The number of observation in exog should match the number of out-of-sample forecasts produced. If the length of exog does not match the number of forecasts, a SpecificationWarning is produced.
- dynamicbool,
optional
The dynamic keyword affects in-sample prediction. If dynamic is False, then the in-sample lagged values are used for prediction. If dynamic is True, then in-sample forecasts are used in place of lagged dependent variables. The first forecast value is start.
- typ
str
{‘linear’, ‘levels’} ‘linear’ : Linear prediction in terms of the differenced endogenous variables.
‘levels’ : Predict the levels of the original endogenous variables.
- start
- Returns
- predict
ndarray
The predicted values.
- predict
Notes
It is recommended to use dates with the time-series models, as the below will probably make clear. However, if ARIMA is used without dates and/or start and end are given as indices, then these indices are in terms of the original, undifferenced series. Ie., given some undifferenced observations:
1970Q1, 1 1970Q2, 1.5 1970Q3, 1.25 1970Q4, 2.25 1971Q1, 1.2 1971Q2, 4.1
1970Q1 is observation 0 in the original series. However, if we fit an ARIMA(p,1,q) model then we lose this first observation through differencing. Therefore, the first observation we can forecast (if using exact MLE) is index 1. In the differenced series this is index 0, but we refer to it as 1 from the original series.