Statalist


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

RE: st: Standard deviation of a moving window


From   "Martin Weiss" <[email protected]>
To   <[email protected]>
Subject   RE: st: Standard deviation of a moving window
Date   Fri, 21 Aug 2009 22:52:15 +0200

<>


Ari wants to take a very hard look at  ?h rolling- which will solve his
problem. Here is a first stab at a solution:


******
clear*
set obs 100

//firms
gen firm=_n
lab var firm "Firm ID"

//expand to # of time periods
expand 10

bys firm: gen year=_n

gen M=rnormal()

compress

tsset firm year

qui rolling r(sd), /* 
 */ window(2) recursive /* 
 */ clear start(1) : su M


rename _stat_1 standev

l if firm<=4, /* 
 */ sepby(firm) noo
******


HTH
Martin



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