On Thu, 28 Aug 2008, Rebecca Zhang wrote:
Can someone take a look to see how I can program in gretl to
achieve below?
Yes, will do.
Below is what I wrote for one run. How to program it so that it
can run in loop?
setobs 12 2000:01
smpl 2000:01 2005:12
ols y const x1 x2 x3
fcast 2006:01 2006:01 --out-of-sample
setobs 12 2000:02
smpl 2000:02 2006:01
ols y const x1 x2 x3
fcast 2006:02 2006:02 --out-of-sample
...
(Each time to move one month forward.)
First of all, unless I'm missing something, I don't think that the
"setobs" command is what you want in your loop. This does not
advance the start of the sample range, rather it tells gretl to
_interpret_ your data as starting at a particular "historical
time" observation. I take it that the algorithm you have in mind
is the following:
(1) Set the sample range to start at time t and end at time t + k.
Estimate a model over this range.
(2) Generate (and record in a useful form) a forecast for period
t + k + 1.
(3) Have we reached the end of the available data? If so, stop;
if not, let t <- t + 1 and go to step (1).
If my interpretation is correct, the way to do this in gretl is
something like the following. (For the sake of concreteness I'm
referencing a particular dataset and model).
<script>
open data9-7
smpl ; 1988:4 # reserve 2 years of quarterly observations
series fc = NA # create a blank series to hold the forecasts
series fci
loop i=1989:1..1990:4
ols 1 0 2 3 4
fcast $i $i fci # generate period-specific forecast
fc[$i] = fci[$i] # and write it into the 'holder'
smpl +1 +1 # advance the start and end of the
# sample by 1 observation
end loop
print 1 fc --byobs # print the results
</script>
Note that you can use the --quiet option with the ols command if
you don't want to see the output from all the models.
Allin Cottrell