Pregunta

After performing the AR(q) fitting I am returned an ARResultsWrapper containing all the parameters and fit statistics. Computing the 95% confidence interval should then be a matter of converting from AR(q) to MA(p) and then doing a cumsum of those coefficients as shown in Section 1.0.2 of [1]. In Python this procedure amounts to:

forecast = model.predict(begin, end)
arparams = params[1:] # drop the constant term
ma_rep = arma2ma(np.r_[1, arparams[::-1]], [1.], forecast.size)
fcasterr = np.sqrt(self.model.sigma2 * np.cumsum(ma_rep**2))
const = norm.ppf(1 - (1-conf)/2.)
confint = np.c_[forecast -  const * fcasterr,forecast +  const * fcasterr]

However, it is not clear whether I am calling the arma2ma method correctly. Should I reverse the order of the coefficients, negate them (as done in [2, 3]), drop the constant term or pass all model.params directly?

[1] http://faculty.washington.edu/ezivot/econ584/notes/forecast.pdf

[2] https://github.com/mkordi/pygwr/blob/b3440687b8f44b23f6a813ef0eefa0664dfb9e75/pygwr/gwstatsmodels/tsa/arima_model.py

[3] https://github.com/statsmodels/statsmodels/blob/master/statsmodels/tsa/ar_model.py

¿Fue útil?

Solución

Here is our use of arma2ma for forecasting standard errors. If you use ARMA and just pass 0 for the MA term instead of AR you should get these. I guess it never got added to AR.

To answer your question, you don't need to reverse the AR coefficients, but you do need to negate them, because of the ARMA representation used for scipy.signal.lfilter.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top