I am using a Matlab toolbox for obtaining one-step ahead forecasts of the conditional mean from the ARMA(1,0)-GARCH(1,1) process and I have encountered a piece of code that contains, in my opinion, a mistake. The full code of the forecasting function is available for viewing at: http://uk.mathworks.com/matlabcentral/fileexchange/32882-armax-garch-k-toolbox--estimation--forecasting--simulation-and-value-at-risk-applications-/content/garchfor.m

The fragment that I was referring to is:

% Forecasting the Mean
MF = parameters(1:1+z)'*[1; data(end-(1:ar)); resids(end-(0:ma-1))]; % 1-period ahead forecast
 for i = 2:max_forecast
     MF(i,1) = sum([parameters(1); ones(1,ar)*parameters(2:2+ar)*MF(i-1,1); ones(1,ma)*parameters(3+ar:2+ar+ma)*resids(end-(0:ma-1-i))]);
 clear i

From this code it seems that when I am considering ARMA(1,0) the function takes the one before last observation for the forecast. In other words, when the data spans time points $1,...,t$ and I want to obtain a forecast for period $t+1$ I multiply the AR(1) coefficient by the $t-1$ observation.In my opinion, for time $t+1$ AR(1) forecast I should be taking the last observation ($t$) from the data-set and multiply it by the AR(1) coefficient.

Could you please confirm my suspicions about this piece of code?


1 Answer 1


The code is correct regarding your question (and only for an AR(1) ), you made a mistake because the last observation of the data set is $t-1$ and not $t$ since you are forecasting the point at time $t$.

In the code : MF(i,1) is the current point forecast ($t$) and lag one observation ( MF(i-1,1) which is $t-1$ ) is correctly related to the AR part.

However it seems to me that there is an error in the following part :


It is only correct if you are estimating an AR(1) , for a higher order the MF(i-1,1) part is wrong because you apply different coefficients to the same observation ( ex : $ \alpha_{1} y_{t-1} + \alpha_{2} y_{t-1} $ instead of $\alpha_{1} y_{t-1} + \alpha_{2} y_{t-2} $ ). I would recommend you to use more reliable codes such as functions you can find in the MFE Toolbox.

  • $\begingroup$ I will investigate the MFE Toolbox, I remember that I couldn't find everything I needed there, but I will give it another look. But back to your answer, I am still not sure I understand correctly. Let's say I have an estimation sample of a 100 observations and an evaluation sample of 1 observation. So when I estimate the ARMA(1,0)-GARCH(1,1) model on the estimation sample and want to make this one one-step ahead forecast of the conditional mean ( for this time = 101) i multiply the AR(1) coefficient by observation number 99 or 100? $\endgroup$
    – Masher
    Dec 28, 2015 at 22:00
  • $\begingroup$ I was investigating this matter with the fGarch package and it seems that 100 would be he answer in this case, as such manual calculations yield the same result as the prediction done using the built-in function. $\endgroup$
    – Masher
    Dec 28, 2015 at 22:03
  • $\begingroup$ to forecast observation 101 you multiply the ar(1) by observation 100, if you fit a AR(2) you multiply ar(1) by obs (100) and ar(2) by obs(99) $\endgroup$
    – Malick
    Dec 28, 2015 at 22:07
  • $\begingroup$ That is what I have though, so only in the case of the one-step ahead out-of-sample AR(1) forecasting MF = parameters(1:1+z)'*[1; data(end); resids(end-(0:ma-1))]; this modification of the code yields the expected result, as leaving data(end-(1:ar)) would result in taking the one before last observation of the estimation sample. Thank you for your help @Malick $\endgroup$
    – Masher
    Dec 28, 2015 at 22:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.