Page 1 of 1

...kind of embarrassing...

Posted: Thu Jul 28, 2011 12:00 pm
by lomfy
i have been trying to do easy stuff, and could'nt figure out how for one hour now:

Series

t EQ1 EQ2 EQ3
1 3 4 1
2 5 1 2
3 2 7 3
4 1 4 2
5 6 6 2
6 3 1 1


I want to create a series EQ which is the sum over all EQs for each point of time:

t EQ
1 8 (from 3+4+1)
2 8 (from 5+1+2)
3 12 ....
4 7
5 14
6 5

how to do this automatically? :shock:

So far I ended up with something like that (which doesnt work):

for !i = 1 to 3
series eq = @sum (eq!i)
next

But this sums up over time, not over the EQ series...

in order to use @rsum i need to define a group, which I don't want to, as all the series EQ!i in the worksheet should be added up as demonstated...

Re: ...kind of embarrassing...

Posted: Thu Jul 28, 2011 12:02 pm
by EViews Gareth
You need to use @rsum. Can you explain why you don't want to use it?

Re: ...kind of embarrassing...

Posted: Fri Jul 29, 2011 12:47 am
by lomfy
this indeed works fine...

well, this calculation is only one of 9 or so which i perform in one program in order to calculate a certain test statistic...as i already have heaps of time series (96*3) my workfile is packed additionally with all those 9 series of variables (the non-cumulative ones of those also have 96 entries each!) created in intermediary steps, which i only use for calculating the final statistic...and additionally i will have to calcultate 3 more test statistics o the same complexity...

thus the intention to save as many entries as possibly possible! however, i'm aware the 1 additional group might not really be the best point to start saving... :D

i guess the statement glenn made at the end of this post ( http://forums.eviews.com/viewtopic.php?f=5&t=4654 ) might be the right hint to clean up my mess of intermediary variables! however as i'm new to eviews, i'm not familiar with this yet...guess it'll be worth looking up the usage of subroutines...

so long...thanks for your support!

Re: ...kind of embarrassing...

Posted: Fri Jul 29, 2011 10:31 am
by EViews Glenn
One comment about the specific question. Intermediate series can be deleted when done and you can sometimes avoid creating them at all. There are many ways to do things in EViews, some better than others in certain circumstances. Suppose, for example, that you have the series Y in your workfile and wish to compute the sum, at each period of
Y, log(Y) and Y^2.

You could create the intermediate series and then the sum

Code: Select all

series logy = log(y) series y2 = y^2 series ysum = y + logy + y2 delete y2 delete ysum
but you could just as easily compute the sum in one expression

Code: Select all

series ysum = y + log(y) + y^2
avoiding the temps altogether.

Note that this does the within period summing that you want. One possible problem is this sum is not robust to missing values so that a missing in one series will propagate to the sum. This may be what you want, but if you wish to compute the sum ignoring the missings, you could do

Code: Select all

group temp y log(y) y^2 series ysum = @rsum(temp) delete temp
as Gareth suggested, or you could do a variant of our initial method

Code: Select all

ysum = @recode(y<>na, y, 0) + @recode(log(y)<>na, log(y), 0) + @recode(y^2<>na, y^2, 0)
This latter method avoids the temporary group but is less efficient.

Re: ...kind of embarrassing...

Posted: Sun Jul 31, 2011 3:12 am
by lomfy
Hi Glenn,

funny you mentioned it, just the day you replied the first thing i thought of when i woke up was "why not simply delete the intermediary series after the calculation" - thanks for the hints on handling this in any case!!

Cheers