Sorry, for writing again. But I should have provided a more tidy example.
Please find attached the two approaches: 1) no bundle involved and 2)
bundle involved computing the rolling forecast of a model.
Best,
Artur
Am 23.01.2017 um 14:23 schrieb Artur Tarassow:
Hi Sven,
let me explain in more detail what I tried to program:
- Send a dataset comprising the first T of total T+k observations to
function F where k>0
- Restrict the dataset to t=1..(T-h) observations within function F
using the "smpl" command
- Forecast the remaining h observations dynamically
This should be doable (I guess) as I just want to access the T
observations which I initially sent to F. The --rolling option seems to
recognize/accept this but for some reason not the --dynamic option.
I just saw that the 2nd illustrative example -- the one which works but
does not involve bundles -- can be simplified as follows:
<hansl>
set verbose off
open denmark.gdt -q
series x = diff(LRY)
function void dynfc (series x, int R, int k)
smpl --no-missing x
scalar t1 = $t1
scalar nsel = t1+(R-2)
scalar n = nobs(x)
scalar nstep = (n-R-k)
loop i=1..nstep -q
if i==1
smpl t1 nsel
endif
# fit to the training test
ols x 0 x(-1 to -2)
# OoS forecast
fcast ($t2+1) ($t2+3) --dynamic
smpl +1 +1 # roll forward
endloop
end function
dynfc(x, 10,1)
</hansl>
Artur
Am 23.01.2017 um 13:41 schrieb Sven Schreiber:
> Am 23.01.2017 um 09:09 schrieb Artur Tarassow:
>> Dear all,
>>
>> I've got a problem with fcast() using it within a bundle context. In the
>> example script below, I want to set up a rolling (both sample start and
>> sample end are moving forward at each iteration) forecast exercise.
>> However, I obtain an issue with the "--dynamic" option.
>>
>> It is about the line "fcast ($t2+1) ($t2+b.k) --dynamic". You could
even
>> try "fcast --dynamic". Surprisingly, the rolling option works:
"fcast
>> ($t2+1) ($t2+b.k) b.k --rolling".
>>
>> I also set up an alternative function which doesn't make use of a
>> bundle, and there it works fine (see the attached file please).
>>
>> Any ideas what's wrong here?
>>
>
> Artur, I find these functions hard to verify in terms of the samples
> they're using. A function typically wouldn't have access to
> out-of-sample observations (with respect to the active sample at the
> time the function is called). It looks as if that could be an issue,
> depending on the values of $t2/$t1/R. Maybe you could add some explicit
> error checks about that.
> However, I agree that it's surprising that --rolling would work if
> --dynamic doesn't. So no, don't have very concrete ideas.
>
> good luck,
> sven
> _______________________________________________
> Gretl-users mailing list
> Gretl-users(a)lists.wfu.edu
>
http://lists.wfu.edu/mailman/listinfo/gretl-users