Am 21.08.2013 09:40, schrieb Sven Schreiber:
Status update: For now it still seems necessary to pre-process the
input. I did that with Python in a 'foreign' block within the gretl
script, and after some trial-and-error passing around the correctly
formatted path strings it works for me as a temporary solution. I will
send the code when I have wrapped the stuff in functions as far as possible.
I'm attaching a hansl file with a couple of relevant functions which
should cover many real-world cases. These functions assume an Alfred csv
file preprocessed like I described before, which resides in the location
specified in the string argument 'fname'. (This path is taken as-is, so
the caller is responsible for getting it right.)
These are the function signatures, where 'vname' is the string variable
holding the variable name as in the Alfred file:
1) getAlf_ithPub(fname,vname,i[0::1])
Retrieves for each observation period (= what I have also called
reference period sometimes) the i-th published value, no matter when
that publication occurred. Can lead to NAs, e.g. for the future or for
high publication numbers.
The case i=0 is special, it gets the final publication for each obs period.
Examples:
series @vname_latest = getAlf_ithPub(fname,vname,0)
series @vname_second = getAlf_ithPub(fname,vname,2)
2) getAlfVintage(fname,vname,day)
Retrieves the vintage valid on date 'day' (which is a string argument in
ISO format), for all obs periods. This is perhaps the classic meaning of
realtime data series. If the vintage date is the present, then this
should coincide with the latest publication: getAlf_ithPub(fname,vname,0).
Will also lead to NAs, e.g. for obs periods that are younger than the
vintage date.
Example:
series @vname_19830302 = getAlfVintage(fname,vname,"1983-03-02")
3) getAlfPubafterN(fname,vname,n)
Retrieves for each obs period the publication which was current as of
(the first day of) the n-th period (quarter or month) after the
respective obs period. So in some sense it imposes a constant
publication lag of n periods, no matter how many publications occur in
between. Also possible in principle is n=0, for variables where the
first publication occurse instantaneously (financial markets?). OTOH,
can lead to NAs especially for low n.
Example:
series @vname_after2 = getAlfPubafterN(fname,vname,2)
In all these cases, the dating (=time axis) in the gretl workfile is
according to observation or reference periods. The publication time of
each value differs in general and depends on the context in a relatively
complicated way.
Of course, much more testing needed.
cheers,
sven