[Gretl-users] Creating a series

Allin Cottrell cottrell at wfu.edu
Wed Mar 28 19:01:20 EDT 2012


On Thu, 29 Mar 2012, Bulent Erdemir wrote:

> I'd like to create a series of which an observation will refer to (or will
> be calculated using) the previous observation of the same series.
>
> For example, I want to end up with a series like below:
>
> 0
> 5
> 10
> 15
> 20
> 25
> 30
>
> Is it possible to create this series with a command similar to:
>
> series s = s(-1) + 5
>
> (Of course, this series can be generated by a formula like obs * 5 but this
> is not what I meant.)
>
> In such a command, one observation will be calculated by a function which
> receives the previous observation.
>
> The command above wouldn't compile with error "The symbol 's' is undefined"
> because at the time of the declaration there's no variable as s.
>
> Could you recommend a solution ?

Yes, define s first:

nulldata 10
series s = 0
s = s(-1) + 5
print s --byobs

Allin Cottrell


More information about the Gretl-users mailing list