Page 1 of 1

Five Year Average in Panel Data

Posted: Mon Aug 12, 2013 1:02 pm
by abdurrub
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)

Re: Five Year Average in Panel Data

Posted: Mon Aug 12, 2013 1:17 pm
by abdurrub
I somehow managed to convert the BALANCED panel data into averages. Now I am only struggling with how to do the UNBALANCED.

Re: Five Year Average in Panel Data

Posted: Mon Aug 12, 2013 1:20 pm
by EViews Gareth

Code: Select all

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

Re: Five Year Average in Panel Data

Posted: Mon Aug 12, 2013 1:29 pm
by abdurrub
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.

Re: Five Year Average in Panel Data

Posted: Mon Aug 12, 2013 1:37 pm
by EViews Gareth
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.

Re: Five Year Average in Panel Data

Posted: Mon Aug 15, 2016 9:35 am
by AngieL
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

Re: Five Year Average in Panel Data

Posted: Mon Aug 15, 2016 10:01 am
by EViews Gareth
No.

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

Re: Five Year Average in Panel Data

Posted: Tue Aug 16, 2016 4:43 am
by AngieL
Hi Gareth,

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

Thank you,
Angie

Re: Five Year Average in Panel Data

Posted: Tue Aug 16, 2016 7:38 am
by EViews Gareth
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.