Calculate the product of all data values in a series?

For questions regarding the import, export and manipulation of data in EViews, including graphing and basic statistics.

Moderators: EViews Gareth, EViews Steve, EViews Moderator, EViews Jason

cuccu
Posts: 5
Joined: Mon Apr 27, 2009 3:03 am

Calculate the product of all data values in a series?

Postby cuccu » Mon Apr 27, 2009 3:18 am

Anyone tells me how to calculate the product of all data values in a series? I cannot find any function to do this. Thanks.

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 13600
Joined: Tue Sep 16, 2008 5:38 pm

Re: Calculate the product of all data values in a series?

Postby EViews Gareth » Mon Apr 27, 2009 8:09 am

@prod(x)

cuccu
Posts: 5
Joined: Mon Apr 27, 2009 3:03 am

Re: Calculate the product of all data values in a series?

Postby cuccu » Mon Apr 27, 2009 9:30 am

scalar sc1 = @prod(FTSE_return)
--> error message: @prod is an illegal name

Plz take a check, QMS Gareth!

I am using EViews 5.0

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 13600
Joined: Tue Sep 16, 2008 5:38 pm

Re: Calculate the product of all data values in a series?

Postby EViews Gareth » Mon Apr 27, 2009 9:40 am

It doesn't work in EViews 5. Please post in the correct forum in the future.

cuccu
Posts: 5
Joined: Mon Apr 27, 2009 3:03 am

Re: Calculate the product of all data values in a series?

Postby cuccu » Tue Apr 28, 2009 9:13 pm

I am using 'for' loop to solve this problem. Thank you, QMS Gareth.

startz
Non-normality and collinearity are NOT problems!
Posts: 3797
Joined: Wed Sep 17, 2008 2:25 pm

Re: Calculate the product of all data values in a series?

Postby startz » Wed Apr 29, 2009 5:45 am

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.

EViews Glenn
EViews Developer
Posts: 2682
Joined: Wed Oct 15, 2008 9:17 am

Re: Calculate the product of all data values in a series?

Postby EViews Glenn » Thu Apr 30, 2009 11:41 am

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)?


Return to “Data Manipulation”

Who is online

Users browsing this forum: No registered users and 2 guests