Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: Re: egen(more) panel data MA by group/year


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   st: Re: egen(more) panel data MA by group/year
Date   Mon, 17 Aug 2009 20:43:09 +0100

-egen, ma()- is no longer documented. It is no longer the best way to do
even moving averages. In fact, since in conception it long predates
-tsset-, -xtset- or panel data it is a very dangerous way to do it
unless you know exactly what you are doing (i.e. have inspected the
source code and verified that it does what you want). 

Moreover, the -ma()- function does not support -by()-, as you state. 

I am confident that no Stata command or function inside or outside of
-egen- supports the last syntax -by(ethnicity)&(year)-. The syntax would
be -by(ethnicity year)-, if it were supported, or -by ethnicity
year:-,ditto. 

I am not clear that you really want a moving average. Your problem
sounds just like one for -egen, mean()-. 

Check out -tssmooth- for moving averages, or -egen, filter()- from
-egenmore- on SSC.  

Nick 
[email protected] 

Steven Archambault

I am trying to get a moving average for a group of observations, per
year, in my panel data. The data observations are individuals, each
with an ethnicity. I want to get the yearly average income of those
individuals by ethnicity.

Essentially, I am trying to do this:

egen inc_avg = ma(income), by(ethnicity)

Stata does not seem to allow -by- for -ma-

I also tried

egen inc_avg = ma(income), by(ethnicity) & (year)

Stata doesn't allow & in this context.


*
*   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/



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