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.