summation notation

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

mattemde
Posts: 9
Joined: Fri Jul 16, 2010 9:02 am

summation notation

Postby mattemde » Fri Jul 23, 2010 10:56 am

Hi,

I'm trying to figure out how to code summation notation into Eviews 7. See attachment for what exactly I'm trying to do. Basically, this notation creates a time series, where the value for each time period t equals a weighted sum over the next 40 periods. R is a time series.

I've written a loop, but thought there must be a more efficient way to do it.

Thanks for your help,
Matt
Attachments
Doc2.doc
(23.5 KiB) Downloaded 493 times

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

Re: summation notation

Postby EViews Glenn » Fri Jul 23, 2010 11:40 am

I'm not certain how efficient your loops are, but what makes this tricky using the efficient series genr routines is that the weights are only a function of the date offset. I can't think of an easy way to do it without loops, but there are probably more and less efficient ways of doing this.

mattemde
Posts: 9
Joined: Fri Jul 16, 2010 9:02 am

Re: summation notation

Postby mattemde » Mon Jul 26, 2010 6:35 am

Here is my loop:

genr z = 0
for !x = 0 to 39
genr zz = r(!x)*(b^!x)*(1 - b)/(1 - b^40)
genr z = z + zz
next


What do you think? Could it be done any better?

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

Re: summation notation

Postby EViews Glenn » Mon Jul 26, 2010 9:55 am

That one is pretty good. I'm assuming that (b^!x)*(1 - b)/(1 - b^40) are the weights.

If memory isn't an issue, you might try something like

Code: Select all

group all for !x=0 to 39 all.add r(!x)*(b^!x)*(1 - b)/(1 - b^40) next series z=@rsum(all) delete all
The idea here is to auto-generate all of the weighted series using leads (like you do), but then to use the @rsum to do the actual summation. Might not make much of a difference since it's basically the same algorithm, but it may eliminate some of the overhead. It would be interesting to see how this compares.

mattemde
Posts: 9
Joined: Fri Jul 16, 2010 9:02 am

Re: summation notation

Postby mattemde » Mon Jul 26, 2010 1:06 pm

The results are identical for the two loops.

Thanks again for your help.

Matt


Return to “Data Manipulation”

Who is online

Users browsing this forum: No registered users and 2 guests