Averages by crossid ("row averages")

For questions regarding the import, export and manipulation of data in EViews, including graphing and basic statistics.

Moderators: EViews Gareth, EViews Steve, EViews Moderator, EViews Jason

huugh
Posts: 14
Joined: Fri Feb 08, 2013 4:04 am

Averages by crossid ("row averages")

Postby huugh » Fri Feb 22, 2013 3:41 am

Hi,
I have a panel data (with T=20 observations, and K=30 cross-sections) and I would like to generate averages for a given time-period for specific groups of cross-sections.
So, let's say I want to generate a series that would represent the average value for crossids 5, 7 and 10.
How can I do this in Eviews?


Ideally I would like to generate a new cross-section that would represent the "row average" of a given crossids. Is this even possible?


(PS: I wonder about the behavior of @mean function -
if I try to generate scalar:

Code: Select all

scalar avg1=@mean(series1, A1)
it produces error "too many arguments", but

Code: Select all

series avg2=@mean(series1, A1)
works (however, it generates the series with the same value in each observation - so why Eviews won't accept the scalar statement?)

Code: Select all

sample A1 if @year=2005 AND (crossid=5 OR crossid=7 OR crossid=10)

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

Re: Averages by crossid ("row averages")

Postby EViews Gareth » Fri Feb 22, 2013 8:36 am

Use the @meansby function.

huugh
Posts: 14
Joined: Fri Feb 08, 2013 4:04 am

Re: Averages by crossid ("row averages")

Postby huugh » Sat Feb 23, 2013 3:25 am

Use the @meansby function.
Thanks. But I still have troubles with declaring the types AND uniquely addressing the observations.
  • I would like to create the new cross-section with the "row average" values. (I.e. if I had values
    1, 2, 3 for K=5
    4, 7, 9, for K=7
    10, 12, 15 for K=10

    I would aim to get a new cross-section K=31, with values 5, 7, 9.

    What I think might work: create a new page with one more cross-section, copy&paste all series into this new page and then use a formula to "fill in" the values for the K=31 cross-section. (E.g. by creating a loop. However, couple of problems with types and addressing the observations arise - please see the comments in code below:

    Code: Select all

    smpl IF crossid=5 OR crossid=7 OR crossid=10 series dummy_crossids=1 smpl @all 'scalar timerange=@max(@obsnum)/@max(@crossid) ’this does work only with series declaration (not scalar), I have no idea why scalar timerange=21 `created manually 'vector(timerange) vector1 'this declaration does not work.. vector(21) vector1 'created manually for !j=1 to timerange step 1 smpl @first+(!j-1) @first+(!j-1) vector1(!j) = @meansby(series1, dummy_crossids) 'does not work (and I am not sure if this syntax does what I want, i.e. returns the average value from the three cross-sections in the given year !j (because @meansby will basically return TWO means, one for dummy_crossids=1 group and one for dummy_crossids=0 group - and I want only the value for dummy_crossids=1) next 'series1(???) = vector1 'here I would like to assign the values stored in the vector1 to the appropriate K=31 cross-section of series1.
  • As described above, I have troubles with the scalar declaration, or as with this example:

    Code: Select all

    vector1 =@meansby(series1, crossid, "1990 2010") 'Does not work series series2=@meansby(series1, crossid, "1990 2010") 'Even though the series declaration works.
    Are there a special rules for scalar or vector declarations, or can you provide a hint what am I doing wrong?



Return to “Data Manipulation”

Who is online

Users browsing this forum: No registered users and 2 guests