Hello all,

I am trying to make a rolling window forecast, but I am having troubles doing so. My goal is to compute one-step ahead forecast by using fixed number of observations (1444 in my case).

That means, that to compute Forecast for observation 1445 I will use AR(1) model with data from observations 1-1444. To compute forecast for observation 1446 I will use AR(1) model with data from observations 2-1445 and so on.

However, I can't get it to work in R, so any help would be greatly appreciated. Cheers

Below is the code that I tried:

```
data.xts$AR1EX_Forecast<-NA
for (s in data.xts$t) {
if(s>=1444 && s<nrow(data.xts)){
model.1=Arima(data.xts$RealizedVariance, order = c(1,0,0), seasonal = FALSE)
forecast=forecast(model.1,h=1)
data.xts$AR1EX_Forecast<- forecast$fitted
}
}
```