Page 1 of 1

how to program it?

Posted: Tue Aug 10, 2010 6:37 am
by tony
how to program it?
y has 20 observations y(1),y(2),y(3),y(4),......y(20) ,I want to extract the first 2 observations and get the maximum denoted x(2),then compute z(2)=x(2)-y(3),loop this ,first 3 observations,the maximum x(3),z(3)=x(3)-y(4),......first 19 obs,x(19),z(19)=x(19)-y(20)
and finally z(2) z(3)......z(19)form a new series z.

Re: how to program it?

Posted: Tue Aug 10, 2010 11:58 pm
by trubador
As far as I understand, you are looking for something like this:

Code: Select all

series z series x = @cummax(y) for !i=2 to 19 z(!i) = x(!i) - y(!i+1) next

Re: how to program it?

Posted: Wed Aug 11, 2010 2:44 am
by tony
yeah,it works.Thank you!