It strikes me that exp(cum(ln(index))) could be more costly both in terms of cycles and
added round-off error (though for the simple stuff I do both are probably trivial). My
concern with exp(cum(ln(index))) is that it will not work if the series contains negative
values?
-----Original Message-----
From: gretl-users-bounces(a)lists.wfu.edu [mailto:gretl-users-bounces@lists.wfu.edu] On
Behalf Of Sven Schreiber
Sent: Monday, August 20, 2012 10:08 AM
To: gretl-users(a)lists.wfu.edu
Subject: Re: [Gretl-users] Cumulative Product
On 08/20/2012 04:49 PM, Riccardo (Jack) Lucchetti wrote:
On Mon, 13 Aug 2012, Allin Cottrell wrote:
> On Mon, 13 Aug 2012, Logan Kelly wrote:
>
>> Is there a cumulative product command similar to the cumulative sum
>> command cum?
>
> Not built-in, but it's trivial to write.
>
> <hansl>
> function series cumprod (series y)
> y = y * y(-1)
> return y
> end function
> </hansl>
Beware the power of logarithms!
<hansl>
nulldata 10
fact = exp(cum(ln(index)))
print index fact -o </hansl>
Completely non-important, but I wonder which is more efficient --
exp(...ln()) seems very costly in terms of complicated nonlinear function evaluations, but
OTOH there's the function call overhead in the user-defined function...
Of course I could just test myself... oh well.
-sven
_______________________________________________
Gretl-users mailing list
Gretl-users(a)lists.wfu.edu
http://lists.wfu.edu/mailman/listinfo/gretl-users