Five Year Average in Panel Data

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

abdurrub
Posts: 14
Joined: Tue Jul 16, 2013 9:08 am

Five Year Average in Panel Data

Postby abdurrub » Mon Aug 12, 2013 1:02 pm

Hi,

I am struggling in creating 5-year averages for every cross section in my panel data.
Any help will be appreciated.

Cross Sections: Countries (189)
Time: years (1950-2010)

abdurrub
Posts: 14
Joined: Tue Jul 16, 2013 9:08 am

Re: Five Year Average in Panel Data

Postby abdurrub » Mon Aug 12, 2013 1:17 pm

I somehow managed to convert the BALANCED panel data into averages. Now I am only struggling with how to do the UNBALANCED.

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

Re: Five Year Average in Panel Data

Postby EViews Gareth » Mon Aug 12, 2013 1:20 pm

Code: Select all

series fiveyears = @recode(@mod(year,5)=0, year, fiveyears(-1)) series means = @meansby(y, fiveyears, @crossid)

abdurrub
Posts: 14
Joined: Tue Jul 16, 2013 9:08 am

Re: Five Year Average in Panel Data

Postby abdurrub » Mon Aug 12, 2013 1:29 pm

I am a beginner, would it be possible if you could explain how to go about the code? I wrote it on the command bar and two var FIVEYEARS and MEANS were made. How to put the observation values in these?

I am sorry, you may not reply to this if I am asking too much.

Thanks a lot for ur reply anyways.

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

Re: Five Year Average in Panel Data

Postby EViews Gareth » Mon Aug 12, 2013 1:37 pm

The series fiveyear that gets created is just a variable equal to "1950" for the first five years, equal to "1955" for the next five years, and so on.

The series means contains the averages.

AngieL
Posts: 17
Joined: Tue Aug 09, 2016 8:17 am

Re: Five Year Average in Panel Data

Postby AngieL » Mon Aug 15, 2016 9:35 am

Hi there,
I have the same problem I tried the formula but I need to do it for every single explanatory variable but the numbers won't change.

Is there another formula I need to use to do for every variable (apart from changing the name in the formula which I have done but it is not working) ?


Thanks,
Angie

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

Re: Five Year Average in Panel Data

Postby EViews Gareth » Mon Aug 15, 2016 10:01 am

No.

You can write a loop that will loop through the variables and create the average.

AngieL
Posts: 17
Joined: Tue Aug 09, 2016 8:17 am

Re: Five Year Average in Panel Data

Postby AngieL » Tue Aug 16, 2016 4:43 am

Hi Gareth,

Thank you for your response. Can you please elaborate because I can not understand?

Thank you,
Angie

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

Re: Five Year Average in Panel Data

Postby EViews Gareth » Tue Aug 16, 2016 7:38 am

You know how to create the five year average for one series, you want to know how to do it for multiple series. I merely stated that you can write a for loop that loops through all your series one at a time and performs the averaging. The programming forum has lots of examples of using for loops.


Return to “Data Manipulation”

Who is online

Users browsing this forum: No registered users and 2 guests