statsmodels.tsa.arima.model.ARIMAResults.extend

ARIMAResults.extend(endog, exog=None, **kwargs)

Recreate the results object for new data that extends the original data

Creates a new result object applied to a new dataset that is assumed to follow directly from the end of the model’s original data. The new results can then be used for analysis or forecasting.

Parameters:
endogarray_like

New observations from the modeled time-series process.

exogarray_like, optional

New observations of exogenous regressors, if applicable.

fit_kwargsdict, optional

Keyword arguments to pass to filter or smooth.

**kwargs

Keyword arguments may be used to modify model specification arguments when created the new model object.

Returns:
results

Updated Results object, that includes results only for the new dataset.

Notes

The endog argument to this method should consist of new observations that occurred directly after the last element of the model’s original endog array. For any other kind of dataset, see the apply method.

This method will apply filtering only to the new data provided by the endog argument, which can be much faster than re-filtering the entire dataset. However, the returned results object will only have results for the new data. To retrieve results for both the new data and the original data, see the append method.

Examples

>>> index = pd.period_range(start='2000', periods=2, freq='Y')
>>> original_observations = pd.Series([1.2, 1.5], index=index)
>>> mod = sm.tsa.SARIMAX(original_observations)
>>> res = mod.fit()
>>> print(res.params)
ar.L1     0.9756
sigma2    0.0889
dtype: float64
>>> print(res.fittedvalues)
2000    0.0000
2001    1.1707
Freq: A-DEC, dtype: float64
>>> print(res.forecast(1))
2002    1.4634
Freq: A-DEC, dtype: float64
>>> new_index = pd.period_range(start='2002', periods=1, freq='Y')
>>> new_observations = pd.Series([0.9], index=new_index)
>>> updated_res = res.extend(new_observations)
>>> print(updated_res.params)
ar.L1     0.9756
sigma2    0.0889
dtype: float64
>>> print(updated_res.fittedvalues)
2002    1.4634
Freq: A-DEC, dtype: float64
>>> print(updated_res.forecast(1))
2003    0.878
Freq: A-DEC, dtype: float64

Last update: Nov 14, 2024