Page 1 of 1
summation notation
Posted: Fri Jul 23, 2010 10:56 am
by mattemde
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
Re: summation notation
Posted: Fri Jul 23, 2010 11:40 am
by EViews Glenn
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.
Re: summation notation
Posted: Mon Jul 26, 2010 6:35 am
by mattemde
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?
Re: summation notation
Posted: Mon Jul 26, 2010 9:55 am
by EViews Glenn
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.
Re: summation notation
Posted: Mon Jul 26, 2010 1:06 pm
by mattemde
The results are identical for the two loops.
Thanks again for your help.
Matt