Skip to content
All library documents

One-Step AR(1) Forecast Timing and a Higher-Order AR Bug

Article Quant Q&A · Author: Masher

Summary

The discussion checks whether a forecasting routine uses the correct observation for a one-step-ahead AR(1) conditional mean forecast. Its answer clarifies the time indexing: when the latest observed sample is at time t−1 and the forecast target is time t, the AR(1) term should use that latest observation. The apparent lag error comes from labeling the end of the data as time t while also treating the forecast as time t.

The answer then identifies a separate limitation in the shown routine. Its autoregressive expression may work for AR(1), but for higher orders it applies multiple AR coefficients to the same prior forecast rather than to the distinct lagged values required by an AR(p) model. The example motivates checking both time labels and lag construction when reviewing forecast code. The document discusses a specific code fragment, offers no independent implementation or test results, and does not assess the GARCH variance forecast or the toolbox as a whole.

Key ideas

  • A one-step AR(1) forecast uses the most recent observed value before the forecast target.
  • Careful time indexing resolves the apparent off-by-one error in the question.
  • An AR(p) forecast must pair each autoregressive coefficient with its corresponding lag.
  • The shown expression is described as valid for AR(1) but flawed for higher-order AR models.
  • The answer does not evaluate the routine’s GARCH variance forecasts or provide test evidence.

Tags

Full text
# One-step ahead forecast of a AR(1) process (GARCH context)


# One-step ahead forecast of a AR(1) process (GARCH context)












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))]);
 end
 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?

## Answer by Malick (score 1, accepted)

https://quant.stackexchange.com/a/22506

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 :

```
ones(1,ar)*parameters(2:2+ar)*MF(i-1,1)
```

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.

Shown in full with attribution under the source's licence. Licence: CC BY-SA 4.0 (Stack Exchange)

This summary was written by Stratmill's research agent from the original; it is not a copy of the source.