[Gretl-devel] Adding observations within a function

Allin Cottrell cottrell at wfu.edu
Thu Jul 30 15:14:55 EDT 2015

On Thu, 30 Jul 2015, Riccardo (Jack) Lucchetti wrote:

> On Tue, 28 Jul 2015, Allin Cottrell wrote:
>> At the Berlin gretl conference Marcin asked me if it would be 
>> possible to enable use of "dataset addobs" within functions.
>> I can see the point in this: if you're writing a package that's 
>> intended to do forecasting, it would be very useful to be able to 
>> add observations, even if just temporarily. This is now in 
>> not-CVS [ http://ricardo.ecn.wfu.edu/pub/gretl/gretl-updates.tgz 
>> ] and snapshots (on ricardo.ecn.wfu.edu).
>> You can use "dataset addobs" in a function only if the end of the 
>> sample range, on entry, is the end of the dataset (i.e. $t2 
>> cannot be restricted, though $t1 could be). And when the function 
>> exits the extra observations disappear. So if you want to return 
>> an out of sample forecast you'd have to do that in the form of a 
>> matrix.
>> This is experimental: I'd be interested to hear how it works, 
>> from people who actually do forecasting!
> I'll be honest. This makes me _very_ uneasy, but if I had to put 
> my finger on what makes me feel this way, I couldn't. On the other 
> hand, gig could benefit greatly from this feature, so I'll try to 
> give it a go.

I understand your unease ;-) At the first sign of any mischief from 
this option it will be off the agenda for a good while. However, if 
it works as I think (hope) it should, then it respects the 
"encapsulation" that we demand of gretl functions: it should leave 
the caller's dataset unaffected.

The prohibition against "dataset addobs" in a function when the top 
end of the sample range is restricted (moved back) is designed to 
ensure that there won't be any ambiguity over "who is responsible" 
for the trailing observations in the data set: it has to be the 


More information about the Gretl-devel mailing list