Summation over an index

For requesting general information about EViews, sharing your own tips and tricks, and information on EViews training or guides.

Moderators: EViews Gareth, EViews Moderator

RDS
Posts: 86
Joined: Thu Feb 17, 2011 9:50 am

Summation over an index

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

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

Re: Summation over an index

I don't understand what you're trying to do.

RDS
Posts: 86
Joined: Thu Feb 17, 2011 9:50 am

Re: Summation over an index

I want to sum

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

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

Re: Summation over an index

Code: Select all

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

RDS
Posts: 86
Joined: Thu Feb 17, 2011 9:50 am

Re: Summation over an index

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

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

Re: Summation over an index

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

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

Re: Summation over an index

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.countseries xs!i = x!i/gsumnext`

RDS
Posts: 86
Joined: Thu Feb 17, 2011 9:50 am

Re: Summation over an index

Sorry for the confusion, they are all scalar

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

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

Re: Summation over an index

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.

RDS
Posts: 86
Joined: Thu Feb 17, 2011 9:50 am

Re: Summation over an index

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

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

Re: Summation over an index

For scalar objects, you'll have to write out the sum manually.