Page 1 of 1
Calculate the product of all data values in a series?
Posted: Mon Apr 27, 2009 3:18 am
by cuccu
Anyone tells me how to calculate the product of all data values in a series? I cannot find any function to do this. Thanks.
Re: Calculate the product of all data values in a series?
Posted: Mon Apr 27, 2009 8:09 am
by EViews Gareth
@prod(x)
Re: Calculate the product of all data values in a series?
Posted: Mon Apr 27, 2009 9:30 am
by cuccu
scalar sc1 = @prod(FTSE_return)
--> error message: @prod is an illegal name
Plz take a check, QMS Gareth!
I am using EViews 5.0
Re: Calculate the product of all data values in a series?
Posted: Mon Apr 27, 2009 9:40 am
by EViews Gareth
It doesn't work in EViews 5. Please post in the
correct forum in the future.
Re: Calculate the product of all data values in a series?
Posted: Tue Apr 28, 2009 9:13 pm
by cuccu
I am using 'for' loop to solve this problem. Thank you, QMS Gareth.
Re: Calculate the product of all data values in a series?
Posted: Wed Apr 29, 2009 5:45 am
by startz
I am using 'for' loop to solve this problem. Thank you, QMS Gareth.
You may also be able to do
Code: Select all
series product=FTSE_return
smpl 2 @last
product = product(-1)*FTSE_return
and then use the last element of product.
Re: Calculate the product of all data values in a series?
Posted: Thu Apr 30, 2009 11:41 am
by EViews Glenn
If all of the values in the series are positive, then
Code: Select all
scalar prod2 = exp(@sum(@log(s1)))
is another v5 way of getting what you want. Note that overflow or zero values are quite common for long series. Are you sure you want the product or do you want to work in a transformed space (e.g., log)?