Page 1 of 1

Summation over an index

Posted: Fri Oct 25, 2013 4:08 am
by RDS
I would like to sum over the index j.

Assume you have 100 time series x(j) and you wish to sum over(j):
y = sum(j, x(j))
with the objective to get the following ratio:
contribution(j) = x(j) / y

This in Eviews 7.2 does not work
for !j = 1 to 100
scalar y = @sum(j,x_{!j})
next

Re: Summation over an index

Posted: Fri Oct 25, 2013 8:46 am
by EViews Gareth
I don't understand what you're trying to do.

Re: Summation over an index

Posted: Fri Oct 25, 2013 9:04 am
by RDS
I want to sum

y = x1 + x2 + x3 + x4 + ...... x100

Re: Summation over an index

Posted: Fri Oct 25, 2013 9:17 am
by EViews Gareth

Code: Select all

group g x* series y = @rsum(g)

Re: Summation over an index

Posted: Fri Oct 25, 2013 9:30 am
by RDS
I KNOW contribution_{!i}_20_1 UP TO contribution_{!i}_20_20

SORRY BUT THIS DOES NOT WORK

for !i = 1 to !n
group g contribution_{!i}_20_*
scalar contribution_{!i}_20_0120 = @rsum(g)
next

Re: Summation over an index

Posted: Fri Oct 25, 2013 9:34 am
by EViews Gareth
I don't understand. I assumed that your Xs were series. How do you want to sum multiple series into a scalar? You want the total sum, over both time and over series? Then that would be:
scalar y = @sum(@rsum(g))

Re: Summation over an index

Posted: Fri Oct 25, 2013 9:58 am
by EViews Glenn
If I had to guess, I think the op wants

Code: Select all

group g x* series gsum = @rsum(g) for !i=1 to g.count series xs!i = x!i/gsum next

Re: Summation over an index

Posted: Fri Oct 25, 2013 9:58 am
by RDS
Sorry for the confusion, they are all scalar

I get an error message when I group using this command _*

Re: Summation over an index

Posted: Fri Oct 25, 2013 10:46 am
by EViews Glenn
I'm completely lost. Could you try again to explain exactly what objects you are starting with (including names) and what you wish to end up with.

Re: Summation over an index

Posted: Tue Nov 05, 2013 10:30 am
by RDS
Assume that I have 100 scalar values: x1_1, x1_2, ....., x1_100
I would like to get the sum: y = x1_1 + x1_2 + ..... + x1_100

Re: Summation over an index

Posted: Tue Nov 05, 2013 10:48 am
by EViews Gareth
For scalar objects, you'll have to write out the sum manually.