Hello,
I think my question is pretty basic, but I am new to e-views, so here it is:
Let's say I have a 4x1 vector X [1,2,3,4] and I want to calculate the average of the first two cells, i.e, [1,2]
What would be the syntax to do that?
Would the same thing work if X is a series?
Thanks in advance.
Calculating average of a part of a vector
Moderators: EViews Gareth, EViews Steve, EViews Moderator, EViews Jason
-
EViews Glenn
- EViews Developer
- Posts: 2682
- Joined: Wed Oct 15, 2008 9:17 am
Re: Calculating average of a part of a vector
For the vector
The arguments to @subextract are startrow, startcol, endrow, endcol.
For a series, set the sample, then compute the mean.
Code: Select all
scalar meanval = @mean(@subextract(vec, 1, 1, 2, 1))
For a series, set the sample, then compute the mean.
Last edited by EViews Glenn on Tue Mar 09, 2010 4:27 pm, edited 1 time in total.
Re: Calculating average of a part of a vector
Got it! Thanks a lot!
Re: Calculating average of a part of a vector
Hello
I have the following series called GSP and I wonder how I could apply the SUBEXTRACT above to calculate the last 3 observations of the series.
2004Q1 31890.13
2004Q2 32013.67
2004Q3 32206.76
2004Q4 32558.51
2005Q1 33615.45
2005Q2 33444.33
2005Q3 34124.03
2005Q4 34598.91
2006Q1 34958.63
2006Q2 36176.06
2006Q3 36060.56
2006Q4 36767.85
2007Q1 37248.44
2007Q2 37909.00
2007Q3 38322.54
2007Q4 38559.05
2008Q1 39835.42
2008Q2 38782.91
2008Q3 39639.01
2008Q4 38996.22
2009Q1 38112.44
2009Q2 39838.41
2009Q3 ?
2009Q4 ?
2010Q1 ?
To obtain the 2009Q3 figure I want to multiply the 2009Q2 by the last 4 period average growth rate of GSP. Similarly, for the 2009Q4 I want to multiply the 2009Q3 by the last 4 period average growth rate of GSP and so forth..
Many thanks, Riaz
I have the following series called GSP and I wonder how I could apply the SUBEXTRACT above to calculate the last 3 observations of the series.
2004Q1 31890.13
2004Q2 32013.67
2004Q3 32206.76
2004Q4 32558.51
2005Q1 33615.45
2005Q2 33444.33
2005Q3 34124.03
2005Q4 34598.91
2006Q1 34958.63
2006Q2 36176.06
2006Q3 36060.56
2006Q4 36767.85
2007Q1 37248.44
2007Q2 37909.00
2007Q3 38322.54
2007Q4 38559.05
2008Q1 39835.42
2008Q2 38782.91
2008Q3 39639.01
2008Q4 38996.22
2009Q1 38112.44
2009Q2 39838.41
2009Q3 ?
2009Q4 ?
2010Q1 ?
To obtain the 2009Q3 figure I want to multiply the 2009Q2 by the last 4 period average growth rate of GSP. Similarly, for the 2009Q4 I want to multiply the 2009Q3 by the last 4 period average growth rate of GSP and so forth..
Many thanks, Riaz
-
EViews Gareth
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13600
- Joined: Tue Sep 16, 2008 5:38 pm
Re: Calculating average of a part of a vector
smpl 2009:3 2010:1
GSP = gdp(-1)*growth
GSP = gdp(-1)*growth
Who is online
Users browsing this forum: No registered users and 2 guests
