Out-of-sample ARMA prediction using statsmodels

I use statsmodels to match the ARMA model.

import statsmodels.api as sm arma = sm.tsa.ARMA(data, order =(4,4)); results = arma.fit( full_output=False, disp=0); 

Where data is a one-dimensional array. I know to get rough predictions:

 pred = results.predict(); 

Now, given the second data set, data2 , how can I use a previously calibrated model to generate a series with forecasts (forecasts) based on these observations?

+12
python statsmodels forecasting
source share
2 answers

I thought there was a problem for this. If you write a github file, Iโ€™m more likely to add something like this. The forecasting mechanism is not yet available as user-defined functions, so you will need to do something like this.

If you have already placed the model, you can do it.

 # this is the nsteps ahead predictor function from statsmodels.tsa.arima_model import _arma_predict_out_of_sample res = sm.tsa.ARMA(y, (3, 2)).fit(trend="nc") # get what you need for predicting one-step ahead params = res.params residuals = res.resid p = res.k_ar q = res.k_ma k_exog = res.k_exog k_trend = res.k_trend steps = 1 _arma_predict_out_of_sample(params, steps, residuals, p, q, k_trend, k_exog, endog=y, exog=None, start=len(y)) 

This is a new forecast for 1 step forward. You can apply this to y and you will need to update the leftovers.

+14
source share

For one-dimensional unscheduled forecasting (test) we can use:

ARMAResults.forecast(steps=1, exog=None, alpha=0.05)

This will be res.forcast(steps=1)

The same is available for ARIMA.

ARIMAResults.forecast(steps=1, exog=None, alpha=0.05)

0
source share

All Articles