Hi Allin,
Well, lately I have been working with JavaScript and Java, and one solution
that I think you could consider is to create an object like notation for
variables. For example, this case you could use:
obs.year==1974
obs==1 (or some other like obs.index)
This way the variables parser would clearly know what do return.
Hélio
On Fri, Feb 12, 2010 at 8:52 PM, Allin Cottrell <cottrell(a)wfu.edu> wrote:
On Fri, 12 Feb 2010, Allin Cottrell wrote:
> The difficulty is this: with quarterly or monthly data there's
> no possible confusion between the alternate forms of identifying
> observations: "obs=1975:4" versus "obs=3", for example. But
with
> annual data confusion is possible. But I'll consider it some
> more.
I'm a little clearer on the issue now. Consider the string on the
right-hand side of "obs==". With quarterly data you can supply,
e.g., "1980:2" and gretl will translate this into an integer that
can be compared with the numerical value of "obs". Or you can
supply, say, "1" and gretl can make the comparison directly.
With annual data, the string representing a year is
indistinguishable from a string representing a general scalar. So
you can't reference observations by year in this context unless we
do the special thing of making the internal "obs" variable produce
the year instead of a 1-based index. And that's what we do right
now.
The downside of current practice is just what you discovered; the
upside is that "obs=<year>" works. In setting this up I was
thinking it would be more helpful in general to be able to
reference observations by year. For example, suppose you want a
dummy for 1974: then "d = (obs==1974)" will do it. But sometimes
you want to reference the extrema of the series, and then it's
easier to say "(obs==1)" than to find the starting year.
(Note that the expressions "Ct[1959]" and "Ct[1]" will both work
to get the first value of an annual series starting in 1959.
That's because we know that in the context "varname[string]" the
string must represent an observation: we look at 1959, see that
it's much too big to be a plain index value for an annual dataset,
and translate it.)
Anyway, I'm not sure what to do about this. Opinions welcome.
Allin
_______________________________________________
Gretl-devel mailing list
Gretl-devel(a)lists.wfu.edu
http://lists.wfu.edu/mailman/listinfo/gretl-devel