Statalist The Stata Listserver


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

st: RE: std dev for a certain range for all obs


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   st: RE: std dev for a certain range for all obs
Date   Wed, 6 Dec 2006 19:30:33 -0000

su abnormal_return if dif < -4 
gen std_dev = r(sd) 

Nick 
[email protected] 

mai mai

> I need to create a variable that is the standard deviation of another
> variable from a certain range of data. However, I need this standard
> deviation to be created for all the observations. That is, I have the
> following data, I want to calculate std_dev as the standard deviation
> of the abnormal_return if dif<-4, but I want that standard dev to be
> pasted for all rnages of difs...like this (where the 1.58 is the
> standard deviation for abnormal_return data for the first 5
> observations):
> 
> obs#   dif    abnormal_return   std_dev
> 1         -9    2.3                       1.58
> 2         -8    2.2                       1.58
> 3         -7    3.3                       1.58
> 4         -6    5.3                       1.58
> 5         -5    1.1                       1.58
> 6         -4    2.3                       1.58
> 7         -3    2.3                       1.58
> 8         -3    2.3                       1.58
> 9         -1    2.3                       1.58

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