Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: st: summarizing data over 3 or 5 year periods for macro panel data.
From
John Luke Gallup <[email protected]>
To
[email protected]
Subject
Re: st: summarizing data over 3 or 5 year periods for macro panel data.
Date
Tue, 19 Jul 2011 20:47:22 -0700
Manhal,
If I understand correctly, you are trying to get just one, rather than 3 observations for each group.
Here are two methods:
1. collapse my mx, by(id idthird)
instead of
bysort id idthird: egen my = mean(y)
2.
bysort id idthird: egen my = mean(y)
by id idthird: gen firstobs = (_n==1)
keep if firstobs
John
John Luke Gallup
Department of Economics
Portland State University
On Jul 19, 2011, at 7:07 PM, Manhal Mohammad Ali wrote:
> Dear Stata users,
>
> For macro panel data sets (where N is not so big and T is moderate),
> researchers and academics summarize or average data over certain
> number of periods for example 3 or 5 or 10 for example in growth
> econometrics.
>
> I have a panel data from 1980 to 2009 for 39 countries and I want to
> average my data over a 3 or 5 year periods for the variables y and x
> to then do regression of average y for 3 or 5 year periods on average
> x for 3 or 5 year period. My variables y and x are gdp and inflation.
> This is what is I did so far for a 3 year period example
>
> egen idthird = seq(), block(3)
> bysort id idthird: egen my = mean(y). Similarly for variable x.
>
> This gives me then a "3 independent years groups averages". Then I
> want to regress 3 period mean or average of y, my on the 3 period
> average of mx.
>
> But this is the type of data I get (I did not put values for y and x
> for simplicity)
> Country year idthird my mx y x
> a 1980 1 2.5 1.9
> b 1981 1 2.5 1.9
> c 1982 1 2.5 1.9
> d 1983 2 2.8 1.3
> e 1984 2 2.8 1.3
> f 1985 2 2.8 1.3
> g 1986 3 1.6 1.3
>
> where 2.5 is the average of the first three years for variable my and
> 1.9 is the average for the first three years for variable mx.
>
> Now how can I regress the average of y for 3 periods, my on mx, the
> average of variable x for 3 periods given that the above data now
> looks the one above.
>
> You can clearly see what the problem is - there is three 2.5 values
> which is average for first three years then there is average of 2.8
> for next three years and so on for variable my and similarly for
> variable mx. Shouldn’t there be one entry of 2.5 for the first group 1
> (1980 -1982) then 2.8 for the next group 2 (1983-1985) for variable my
> and similarly for variable mx.
>
> My basic problem and question is how to generate a sequence of
> variables summarized over 3 ot 5 periods and the do regression using
> those new averaged variables. I would really appreciate your kind help
> as I am doing an MSc dissertation and I am little running back
> Thank you very much.
>
> Manhal Ali
> University of Bristol.
>
> *
> * For searches and help try:
> * http://www.stata.com/help.cgi?search
> * http://www.stata.com/support/statalist/faq
> * http://www.ats.ucla.edu/stat/stata/
>
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/