On Sun, 24 Oct 2021, Sven Schreiber wrote:
Am 24.10.2021 um 21:40 schrieb Allin Cottrell:
> On Sun, 24 Oct 2021, Sven Schreiber wrote:
>> heylist(diff(LRM)) # works!
>> list oi = heylist(diff(LRM)) # fails
>> </hansl>
>
> Specifically, the second case fails with the error message:
>
> "heylist: argument 1 is of the wrong type (is list, should be series)"
>
> In the second case gretl notices that the statement as a whole involves
> assignment to a list object. Trying to be helpful, it therefore "casts"
> the argument to diff(), namely LRM, to a single-member list. This
> _would_ in fact be helpful if the statement were of the simpler form
>
> list oi = diff(LRM) # call it case B
>
> Why? Because diff(LRM), without a cast to list for the argument,
> produces an anonymous series, and only named series (members of the
> dataset) can be put into lists.
Hm, thanks for the explanation...
> Clearly, gretl is not clever enough here: in the heylist() context
> "diff(LRM)" _should_ produce an anonymous series result; this expression
> is supposed to create an argument to a function that wants a series.
> Gretl doesn't understand that, unlike case B, "diff(LRM)" occurs in an
> "opaque" context as an argument to heylist().
Let me just note that it wouldn't be such a big problem if in this case
diff(LRM) did produce a hardwired-prefix-named internal new series
d_LRM, I think, in analogy to what diff() does to list members. I'm just
saying it doesn't have to be anonymous, FWIW.
I think it does have to be anonymous. Given a series x, a statement
such as
series foo = 100*diff(x)/x(-1)
must not add a series d_x to the dataset; the result of diff(x) is
strictly a throw-away anonymous series. And a statement such as
series mydiff = diff(x)
must not add a shadow series under the name d_x; in this case the
user has taken charge of naming the new series.
But we need to think about this some more. Just eliminating the
series-to-list cast breaks the packages FEP, CommonTrendsTest, ridge
and robust_RESET.
Allin