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

st: Calculating Empirical CDFs


From   "Yvonne Capstick" <[email protected]>
To   [email protected]
Subject   st: Calculating Empirical CDFs
Date   Tue, 28 Dec 2004 13:36:14 -0500

Hi,

I�ve using Stata to do some returns analysis, and have converted daily returns into standardized normal variables, nret. I now would like to calculate the fraction, F(z) of nret that are less than -3, -2, -1, 0, 1, 2, 3 and then calculate the standard deviation of F(z), using the formula stdev(F(z)) = (F(z))(1-F(z))/n)^0.5.

I can generate the number of observations less than each cut-off using:

forvalues z=-3/3 {
count if nret < `z'
}

and then can copy the results into Excel to generate the fractions and standard errors, but I can�t work out how to do this all in Stata. Whilst the �count� function can give me the number of observations below each cut-off point, I�m not sure how to save these results as a variable to do any calculations with them. I�m using Stata 8, which doesn�t seem to allow me to do a egen temp = count(x) like previous Stata versions.

Separately, I would like to calculate the standard deviation of returns for a particular year, e.g. egen stdev = stdev(nret), by(year), but there doesn�t seem to be a stdev function (or any variants). The �summarize� function gives me standard deviations but doesn�t store these as a variable. I�ve been able to calculate the standard deviation manually, by squaring the normalized returns and dividing them by the total number of observations less one, but thought that Stata must have a function to do this.

Any help would be much appreciated.

Thanks, YC

_________________________________________________________________
Don�t just search. Find. Check out the new MSN Search! http://search.msn.click-url.com/go/onm00200636ave/direct/01/

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