Pirre,

 

Here’s a snippet from a script I wrote a while ago to do rolling correlations. You should be able to modify it to do what you want.

 

<hansl>

nper = 12 # frequency of data

window = 10 # number of years' worth of data per regression

 

begdate = obsnum(1986:02)

enddate = begdate+nper*window

 

loop while enddate<=obsnum(2002:12) --quiet

smpl begdate enddate 

# do estimation, forecasting, etc.

 

begdate++

enddate++

endloop

 

smpl --full

<\hansl>

 

HTH,

 

PS

 

From: gretl-users-bounces@lists.wfu.edu [mailto:gretl-users-bounces@lists.wfu.edu] On Behalf Of pirre andersson
Sent: Tuesday, May 14, 2013 9:34 AM
To: gretl-users@lists.wfu.edu
Subject: [Gretl-users] Rolling forecast with fixed estimation window

 

Hi, im new to gretl and this mail list but i thought i'd give it a chance.
 
Im currently doing a comparison between recursive and rolling forecats with h-step ahead (1,3,6)
 
The script im trying to use i found in an earlier mail from the archive and i tried to modify it abit to suit my needs.
currently it looks like
 
open kandidat.gdt
scalar DataLen = $nobs
scalar WindowLen = 191
scalar FirstObs = 1
scalar LastObs = WindowLen
matrix FCMat = zeros(DataLen, DataLen - LastObs)
scalar j = 1

loop t = LastObs + 1..DataLen - 1
smpl FirstObs LastObs
ols OMX30 const OMX30(-1) OMX30(-2) OMX30(-3) OMX30(-4) OMX30(-5) OMX30(-6) OMX30(-7) OMX30(-8) OMX30(-9) OMX30(-10) OMX30(-11) OMX30(-12) --robust --quiet
smpl 1986:2 2002:12
fcast FSeries (#is it possible to add --rolling and --out-of-sample here)
FCMat[,j] = FSeries
FirstObs = FirstObs + 1
LastObs = LastObs + 1
j++
endloop > ># drop missing values and print >FCMat = FCMat[4:,]
print FCMat
 
What i want to do is for example to try and use 1986:2-2002:12 as the initial estimation period and roll the window forward while dropping the first obsvervation for each step i move "forward".  
Then do out of sample forecasts for  2003:1 to 2012:12 while keeping the estimation window rolling at 191observations and doing either 1,3 or 6 steap ahead forecast.
 
Is this possible and in that case
 
Best regards
Pierre