Am 14.09.2019 um 21:40 schrieb Burak Korkusuz:
Hi,
I have 2000 obs. in total which is 5 minutes realised variance. I
will have an HAR model (for example: ols x constant x(-1) a b) with an
initial sample 1-500 obs. and I am going to forecast 501. obs. Next, I
will have the initial sample 2-501 obs. and forecast 502. obs. And again
initial sample 3-502 and forecast 503. obs. ... up until 2000. obs. Each
time, I need to re-estimate my HAR model with initial sample and
forecast next one, which is rolling windows forecasting.
I could not find the codes for this purpose. Is it possible to do
that in gretl?
This type of question is asked every once in a while on this list, I
guess we should add an example to the "cheat sheet" chapter in the guide
or something like that.
The general scripting pattern would go something like this:
<hansl>
series lhs = x
list RHS = const x(-1) a b
window = 500
smpl 1 window
series foutput = NA
loop while $t2 < $tmax # sample end within dataset range
ols lhs RHS
fcast $t2+1 $t2+1 # forecast 1 obs beyond end of sample
foutput[$t2+1] = $fcast # store result
smpl +1 +1 # roll the window
endloop
</hansl>
If you also want to have a forecast beyond the dataset range (where you
don't have a realization to compare it with) you would probably have to
do 'dataset addobs 1' first, and then you could replace '$t2 < $tmax'
with '$t2 <= $tmax'.
hth
sven