On Mon, 15 Feb 2010, Ignacio Diaz-Emparanza wrote:
El lun, 15-02-2010 a las 10:57 +0100, Ignacio Diaz-Emparanza
escribió:
> El vie, 12-02-2010 a las 13:44 -0500, Allin Cottrell escribió:
> > On Fri, 12 Feb 2010, Ignacio Diaz-Emparanza wrote:
> >
> > > With periodicity ($pd)> 1 (quarterly or monthly data,..)
> > > y[1] is refering to the first observation of the series,
> > > but with annual data it is refering to the observation of year
'1'.
> >
> > Duh, sorry, I wasn't paying enough attention. I'll think about it,
> > but here's a quick work-around:
> >
> > <script>
> > open data3-6
> > series y = Ct
> > series s1 = 0
> > scalar d = 0.5
> > scalar T = $nobs
> > loop t=1..T
> > s1[t] = (t==1) ? y[t] : d*y[t]+ (1-d)*s1[t-1]
> > endloop
> > print y s1 -o
> > </script>
>
> Oh, yes it works ! I did not try with 't' because I thought it was an
> alias of 'obs', given the explanation in the function reference:
Sorry I am seeing I was absolutely confused about that. I didn't notice
that you were using a loop in 't'. In general in genr commands really
't' is an alias of 'obs'. So the problem persists also with 't'.
OK, I think I have a solution. As you suggested originally, we'll
make "obs" consistent, such that it always gives a series
containing the 1-based index of the observations, regardless of
the periodicity of the data.
This means that, e.g., "(obs==1970)" will not work to pick out the
observation for 1970 in an annual time series. But if you want to
do that you can use the function obsnum(), as in
series d70 = (obs==obsnum(1970))? 1 : 0
(I had forgotten about obsnum, but it's clearly the tool for the
job here.)
Allin.