Pseudo forecasting (Rolling)

Asked

Viewed 180 times

6

How to make pseudo predictions out of the sample, through rolling regressions and with mobile window containing 50 observations, to t = 51 to 100? One of the predictions should be made from an AR(1). Another will be made from a random walk, i.e., yt+1(estimated)=yt . Finally, another forecast will be made using the true coefficients:yt+1(estimated)=2+0,7yt . Store forecasts for each model in matrices (or vectors). Estimate AR(1) using MQO (lm(y~x)).

A forecast for the model with true coefficients would be as follows, (With mu=2 and Phi=0.7, previously defined):

for (i in 1:R){
            y[i+1]=mu+phi*y[i]
}

reg=lm(y[i+1]~y[i])

But I’m not getting to understand how to incorporate this model with the true coefficients when making the rolling forecast, since it regresses the forecast windows (xt and xt1).

ar=1
for (i in 1:length(f)) {
            xt=window(x,start=c(year_start+i),end=c(year_start,R+i))
            xt1=window(x,start=c(year_start+i-1),end=c(year_start,R+i-1))
            for(p in 1:ar){xt1=cbind(xt1,lag(xt,-p))}
            y=na.omit(xt1)
            reg=lm(y[,1]~y[,2])
            cond.x=rev(tail(xt,ar))
            f[i]=reg$coefficients%*%c(1,cond.x)                                                     
            frw[i]=tail(xt,1)                                 
}

I tried to include the true model loop inside the rolling forecast loop, but it’s not coming out. I managed to do it with an AR(1) any, but not by incorporating the true coefficients. Someone would have a tip?

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.