On Mon, 12 Dec 2011, Sven Schreiber wrote:
Well I'll keep trying to trigger it [a bad error message
on accessing a forecast-matrix row]
But in general, if gretl cannot figure out the lagged dependent
variables...
If you'll pardon me, gretl would have needed a crystal ball to
figure out that a lagged dependent variable was intended in the
script you posted: you passed the series in question by value.
and thus cannot really do a forecast, shouldn't it throw an error
already at the 'fcast' command, and not "wait" until the user
tries to access the results via '$fcast'?
In the case you posted, a one-step ahead forecast was possible but a
forecast over the full range specified was not. I'm not sure whether
it's preferable to flag an error, or just do what's possible. The
rows() function will tell you how many rows you got. But maybe we
should flag an error all the same.
Anyway, here's an attempt to reproduce something like what you
described (incremental forecasting); it works OK with CVS:
<hansl>
function matrix mfcast(list lhs, list rhs, int t2)
list allrhs = null
loop foreach i lhs -q
list rhs_$i = lags(1, rhs)
if i=1
allrhs = const rhs_$i
else
allrhs = allrhs ; const rhs_$i
endif
endloop
smpl ; t2
system method=SUR
equations lhs allrhs
end system --quiet
scalar fc1 = t2 + 1
scalar fc2 = t2 + 3
fcast fc1 fc2
matrix fc = $fcast
return fc
end function
open denmark
dataset addobs 3
list lhs = IBO IDE LRM LRY
list rhs = LRM
scalar t2 = 1987:1
loop 3 -q
matrix fc = mfcast(lhs,rhs,t2)
print fc
t2 += 1
endloop
</hansl>
Allin