statsmodels.tsa.statespace.varmax.VARMAXResults.append

VARMAXResults.append(endog, exog=None, refit=False, fit_kwargs=None, copy_initialization=False, **kwargs)

Recreate the results object with new data appended to the original data

Creates a new result object applied to a dataset that is created by appending new data to 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.

refitbool, optional

Whether to re-fit the parameters, based on the combined dataset. Default is False (so parameters from the current results object are used to create the new results object).

copy_initializationbool, optional

Whether or not to copy the initialization from the current results set to the new model. Default is False

fit_kwargsdict, optional

Keyword arguments to pass to fit (if refit=True) or filter / smooth.

copy_initializationbool, optional
**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 from both the original dataset and the new dataset.

Notes

The endog and exog arguments to this method must be formatted in the same way (e.g. Pandas Series versus Numpy array) as were the endog and exog arrays passed to the original model.

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

This method will apply filtering to all of the original data as well as to the new data. To apply filtering only to the new data (which can be much faster if the original dataset is large), see the extend 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.append(new_observations)
>>> print(updated_res.params)
ar.L1     0.9756
sigma2    0.0889
dtype: float64
>>> print(updated_res.fittedvalues)
2000    0.0000
2001    1.1707
2002    1.4634
Freq: A-DEC, dtype: float64
>>> print(updated_res.forecast(1))
2003    0.878
Freq: A-DEC, dtype: float64

Last update: Dec 14, 2023