# ARMA-GARCH python implementation

When it comes to predicting timeseries with ARMA-GARCH, the conditonal mean is modeled using an ARMA process and the conditional variance with a GARCH process.

I've seen tutorials predicting returns as follows:

from arch import arch_model
from statsmodels.tsa.arima_model import ARIMA

returns = ...
arima_model_fitted = ARIMA(returns, order=(3, 0, 2)).fit(method='mle', trend='nc')
p_ = arima_model_fitted.order[0]
o_ = arima_model_fitted.order[1]
q_ = arima_model_fitted.order[2]
archm = arch_model(arima_model_fitted.resid, p=p_, o=o_, q=q_, dist='StudentsT')
arch_model_fitted = archm.fit()

next_return = arch_model_fitted.forecast(horizon=1).mean['h.1'].iloc[-1]


What I think is peculiar is that the fitted GARCH model is used to predict the next return. Doesn't this predict the residual instead of the return?

I would predict the next return as follows:

mu_pred = arima_model_fitted.forecast()[0]
et_pred = arch_model_fitted.forecast(horizon=1).mean['h.1'].iloc[-1]

# yt = mu + et
next_return = mu_pred + et_pred


I am, however, unsure that this is correct.

• Where did you see this tutorial? Link it if you can.. I would agree with you 100%
– Fr1
Aug 8, 2019 at 14:04
• It is correct if they write the coded version of next_return=mu_pred+sqrt(Garch)*t_student_innov in which case they would simulate (not predict!) the next return.. but if et_pred is the garch/arch forecasted conditional variance as it seems to be, then the forecast is wrong here.. even if from here I cannot see what “mean[‘h.1’].iloc[-1]” tries to retrieve, that could be key..
– Fr1
Aug 8, 2019 at 14:08
• From arch.readthedocs.io/en/latest/univariate/…: there's three elements in a ARCHModelForecast. Mean (forecast values cond. mean of the process) , Variance(forecast values cond. var of the process) and Residual Variance (forecast values cond. mean of the residuals). Which I believe still makes the tutorial wrong? Aug 8, 2019 at 14:36
• Ok I have seen the docs thanks for linking, yes it was as expected, so it seems like this tutorial is faulty in the last line because et_pred is the best prediction for the squared residuals at time t+1 (y-mu_pred)^2 given the current info set at time t.. so it does not predict y
– Fr1
Aug 8, 2019 at 14:44
• Thanks for your time @Fr1 ! Aug 8, 2019 at 15:04