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: 85
Joined: Thu Feb 17, 2011 9:50 am

Summation over an index

Postby RDS » Fri Oct 25, 2013 4:08 am

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: 12316
Joined: Tue Sep 16, 2008 5:38 pm

Re: Summation over an index

Postby EViews Gareth » Fri Oct 25, 2013 8:46 am

I don't understand what you're trying to do.
Follow us on Twitter @IHSEViews

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

Re: Summation over an index

Postby RDS » Fri Oct 25, 2013 9:04 am

I want to sum

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

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

Re: Summation over an index

Postby EViews Gareth » Fri Oct 25, 2013 9:17 am

Code: Select all

group g x*
series y = @rsum(g)
Follow us on Twitter @IHSEViews

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

Re: Summation over an index

Postby RDS » Fri Oct 25, 2013 9:30 am

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: 12316
Joined: Tue Sep 16, 2008 5:38 pm

Re: Summation over an index

Postby EViews Gareth » Fri Oct 25, 2013 9:34 am

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))
Follow us on Twitter @IHSEViews

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

Re: Summation over an index

Postby EViews Glenn » Fri Oct 25, 2013 9:58 am

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

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

Re: Summation over an index

Postby RDS » Fri Oct 25, 2013 9:58 am

Sorry for the confusion, they are all scalar

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

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

Re: Summation over an index

Postby EViews Glenn » Fri Oct 25, 2013 10:46 am

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: 85
Joined: Thu Feb 17, 2011 9:50 am

Re: Summation over an index

Postby RDS » Tue Nov 05, 2013 10:30 am

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: 12316
Joined: Tue Sep 16, 2008 5:38 pm

Re: Summation over an index

Postby EViews Gareth » Tue Nov 05, 2013 10:48 am

For scalar objects, you'll have to write out the sum manually.
Follow us on Twitter @IHSEViews


Return to “General Information and Tips and Tricks”

Who is online

Users browsing this forum: No registered users and 4 guests