Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

RE: st: monthly moving average


From   Ana Gabriela Guerrero Serdan <ag_guerreroserdan@yahoo.com>
To   statalist@hsphsun2.harvard.edu
Subject   RE: st: monthly moving average
Date   Wed, 28 Mar 2007 07:42:46 -0700 (PDT)

Dear Maarten and all, 

Thanks I think I got it. I decided to keep the
individual-base data. So my calculations would be:

//To generate a time variable for month and year

gen mdate= ym(year, month)
format mdate %tm
tab1 mdate

//to create a log file
log using "C:\Documents and Settings\gaby\My
Documents\Gaby
Backup\IBC\MovingMonthlyProportion.smcl", replace

//to calculate proportions moving in a monthly basis 

proportion female if mdate> ym(2003, 3)
proportion female if mdate> ym(2003, 4)
proportion female if mdate> ym(2003, 5)
...
...
...
proportion female if mdate> ym(2006, 10)
proportion female if mdate> ym(2006, 11)

// we loose the last month of observations

log close

drop mdate

Thanks, 

regards, 
Gaby 

--- Maarten Buis <M.Buis@fsw.vu.nl> wrote:

> Maybe someone who is currently working with panel
> data can answer this one.
> 
> -----------------------------------------
> Maarten L. Buis
> Department of Social Research Methodology 
> Vrije Universiteit Amsterdam 
> Boelelaan 1081 
> 1081 HV Amsterdam 
> The Netherlands
> 
> visiting address:
> Buitenveldertselaan 3 (Metropolitan), room Z434 
> 
> +31 20 5986715
> 
> http://home.fsw.vu.nl/m.buis/
> -----------------------------------------
> 
> -----Original Message-----
> From: owner-statalist@hsphsun2.harvard.edu
> [mailto:owner-statalist@hsphsun2.harvard.edu]On
> Behalf Of Ana Gabriela Guerrero Serdan
> Sent: woensdag 28 maart 2007 12:33
> To: statalist@hsphsun2.harvard.edu
> Subject: Re: st: monthly moving average 
> 
> Dear Maarten,
> 
> thanks. I actually want to do a moving "proportion".
> Sorry for being clear.
> 
>  Since I had data at the individual level, I have
> created another dataset that sums the deaths per
> month. I can calculate the proportion permonth, but
> I
> want to create a moving proportion which will be for
> Proportion1=# female/total population for all
> months,
> all years. For Proportion2= # female/total for
> months2-12 under year 2003 and all months next
> years.
> Etc.. so the tssmooth ma will give me an average and
> I
> think I can only lead N/2. What I did is after using
> collapse (sum) :
> 
> sort year month
> 
> . list  month year female male sex_unknown  total
> 
> +-------------------------------------------------+
> month   year   female   male   sex_un~n   total
> -------------------------------------------------
> 1.      3   2003      182    264       5915    6361
> 2.      4   2003       72    109       1798    1979
> 3.      5   2003       24    371         68     463
> 4.      6   2003       31    447         94     572
> 5.      7   2003       34    523         37     594
> -------------------------------------------------
> 6.      8   2003       43    587        111     741
> 7.      9   2003       33    435         36     504
> 8.     10   2003       27    331         94     452
> 9.     11   2003       29    351         34     414
> 10.     12   2003       27    411         48     486
> -------------------------------------------------
> 11.      1   2004       33    415         79     527
> 12.      2   2004       24    374        149     547
> 13.      3   2004       55    606        257     918
> 14.      4   2004      205    400        588    1193
> 
> 
> Then I can generate a proportion just by
> using gen=sum(female)/sum(total) but how can I
> specify
> that this has to be calculated by moving downwards
> one
> month every time?
> 
> Also, If I use monthly data instead of individual
> data
> I cant calculate the confidence intervals.
> 
> So what do you suggest?
> 
> Thanks again.
> 
> Regards,
> Gaby
> 
> 
> 
> 
> --- Maarten buis <maartenbuis@yahoo.co.uk> wrote:
> 
> > --- Ana Gabriela Guerrero Serdan
> > <ag_guerreroserdan@yahoo.com> wrote:
> > > I want to create a program that will calculate
> the
> > proportion of
> > > women or men as a moving average. This
> proportion
> > will move per
> > > month.
> >
> > see -help tssmooth ma-
> >
> > Hope this helps,
> > Maarten
> >
> > -----------------------------------------
> > Maarten L. Buis
> > Department of Social Research Methodology
> > Vrije Universiteit Amsterdam
> > Boelelaan 1081
> > 1081 HV Amsterdam
> > The Netherlands
> >
> > visiting address:
> > Buitenveldertselaan 3 (Metropolitan), room Z434
> >
> > +31 20 5986715
> >
> > http://home.fsw.vu.nl/m.buis/
> > -----------------------------------------
> >
> >
> >              
> >
>
___________________________________________________________
> >
> > What kind of emailer are you? Find out today - get
> a
> > free analysis of your email personality. Take the
> > quiz at the Yahoo! Mail Championship.
> >
>
http://uk.rd.yahoo.com/evt=44106/*http://mail.yahoo.net/uk
> >
> > *
> > *   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/
> 
> *
> *   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index