Am 30.12.2020 um 17:32 schrieb Artur Bala:
Le mer. 30 déc. 2020 à 14:28, Artur Bala <artur.bala.tn(a)gmail.com
<mailto:artur.bala.tn@gmail.com>> a écrit :
Le mer. 30 déc. 2020 à 13:59, Sven Schreiber <svetosch(a)gmx.net
<mailto:svetosch@gmx.net>> a écrit :
I don't see this problem here. You might have to send us a
self-contained example, preferably with one of gretl's shipped
datasets.
Thank you Sven. I'll manage to send it over.
Hi Sven,
Here's attached the function. Does this help?
Please note that the function still needs some fine-tuning.
In the sample script I also included 2 lines (refering to "lever") that
make the function fail.
Ah OK, I see what you mean. Of course the error message is misleading,
but see below.
I guess it's a gretl bug. Here's my hypothesis:
- As per the doc 'leverage --save' uses 'lever' for the saved series
only when such a series doesn't already exist. Otherwise it uses a
different name (lever_aaa I think).
- So in your second invocation gretl looks in the outer-scope dataset
(which it shouldn't do!), sees a 'lever' series there, and saves the
series under a different name. Then when you try to access 'lever'
inside your function gretl doesn't find it because it only looks in the
function scope (which is correct!). Hence the unknown object message.
So the bug might be that gretl mixes up the outer and inner scopes here.
As a workaround perhaps you could use the series ID numbers instead:
Before you run 'leverage' check what's the highest existing ID number,
for example with nelem(dataset); then the new lever-style series should
have this ID number +1, no matter what its name is.
cheers
sven