Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: Re: taking averages of panel data


From   "R.E. De Hoyos" <[email protected]>
To   <[email protected]>
Subject   st: Re: taking averages of panel data
Date   Fri, 27 Feb 2004 22:16:37 -0000

(1) you can create average values within a period of time:

bys country: egen average_inf = mean(inflation) if inrange(year,1995,1999)

(2) transform your variables to means:

collapse variable_list by year

Finally you -merge- them using country as your id.


Rafa

______________________________
R.E. De Hoyos
Department of Applied Economics
University of Cambridge
Cambridge, CB3 9DE, UK
Tel: +44 1223 335269


----- Original Message -----
From: <[email protected]>
To: <[email protected]>
Sent: Friday, February 27, 2004 9:01 PM
Subject: st: taking averages of panel data


> Hi,
>
> I have two questions.
>
> (1) I have a panel data covering 1994-2001, that has both firm-level and
> country-level data from multiple countries.  I want to run cross-sectional
> regressions using averages across certain years.  Can I just take averages
> of certain years for some variables and regress them on averages of
another
> variable? Can I regress them on observations of another variable from only
> a particular year?
>
> Example:    regress per capita income in 1999 on average inflation from
> 1995-1999 and on average bank margin from 1995-1999 OR
>             regress average per capita income from 1995-1999 on avg.
> inflation 1995-1999 and on avg. bank margin 1995-1999
>
> Can I do this in Stata, or do I have to take averages in some other
program
> and then convert it into a Stata dataset? What would be the easiest way of
> doing this?
>
> (2) I have two datasets: one is the panel above.  The other has
> cross-country data from 1999 only.  What I want to do is run
> cross-sectional regressions using data from both datasets.  I want to take
> the averages of some variables over certain years (e.g. 1995-1999) from
the
> panel data and regress them on the 1999 data from the other dataset.  Do I
> need to merge the datasets? How do I merge a panel with a cross-sectional
> dataset?
>
> I am new to the list, and I never did panel data analysis in Stata, so I
> apologize in advance if the answer to this was easy to find elsewhere.  I
> would appreciate your help.
>
> Regards,
> Mehmet Genc
>
>
> *
> *   For searches and help try:
> *   http://www.stata.com/support/faqs/res/findit.html
> *   http://www.stata.com/support/statalist/faq
> *   http://www.ats.ucla.edu/stat/stata/
>
*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index