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

Re: st: Re: Moving Average


From   Ernest Berkhout <[email protected]>
To   [email protected]
Subject   Re: st: Re: Moving Average
Date   Mon, 12 May 2003 11:37:25 +0200

At 23:26 9-5-2003, you wrote:
> Is there a way to force Stata to calculate a moving average using an EVEN
number?  I am trying to calculate ma() over several years, and a 12 month
moving ave. makes the most sense.
I had the same kind of problem, and I tackled that with a simple "generate" and explicit subscripting.
Essential is it that the data are in long format, and that you sort on the timevariable first.

bysort (QUARTER): gen zkd_smooth4 = ( PLOTVAR[_n] + PLOTVAR[_n-1] + PLOTVAR[_n-2] + PLOTVAR[_n-3] )/4


Ernest Berkhout
Stichting voor Economisch Onderzoek
Universiteit van Amsterdam

De SEO is verhuisd! Tegenwoordig ben ik bereikbaar op:
Kamer 3.08
Roetersstraat 29
1018 WB Amsterdam

tel.:+ 31 20 525 1630
fax:+ 31 20 525 1686
http://www.seo.nl
=================================
"To an economist, real life is a special case"
=================================

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