Statalist


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

RE: st: moving standard deviation (panel data)


From   "Nick Cox" <n.j.cox@durham.ac.uk>
To   <statalist@hsphsun2.harvard.edu>
Subject   RE: st: moving standard deviation (panel data)
Date   Thu, 11 Oct 2007 17:00:01 +0100

Typo time: 

bys id (yr): g sc=sqrt((c^2+l.c^2+l2.c^2)/3-((c+l.c+l.c)/3)^2)

should presumably be 

bys id (yr): g sc=sqrt((c^2+l.c^2+l2.c^2)/3-((c+l.c+l2.c)/3)^2)

Caveat lector! 

Nick 
n.j.cox@durham.ac.uk 

Austin Nichols
 
> webuse grunfeld, clear
> ren com id
> ren year yr
> tsset id yr
> g c=d.mval
> la var c "Change in mvalue"
> bys id (yr): g sc=sqrt((c^2+l.c^2+l2.c^2)/3-((c+l.c+l.c)/3)^2)
> * Optional correction (pop sd vs sample sd):
> replace sc=sqrt(3/2)*sc
> la var sc "SD of change in mvalue over prior 3 yrs"
> 
> and see -help tsvarlist- for more.
> 
> On 10/10/07, west--@libero.it <west--@libero.it> wrote:
> > Hi,
> >
> > I know this should be simple but I just don't know what 
> commands I have to type in order to get Stata 9.2 to run a 
> moving 'standard deviation' for one variable of my panel 
> (2892 companies, years: 1995:2005). Basically, the new 
> variable should be measured as the standard deviation of the 
> change in 'earnings' over a three-year period. I wish to 
> measure the changes from year t-3 until year t. Whenever 
> (randomly, for some years) there are no data available, no 
> standard deviation is computed. That's all.

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