Hello everyone,
For my Replication Study, I am replicating a study for which I need the variable 'Return Volatility'. This is measured as the 'standard deviation of monthly stock returns over three years prior to t'. I am new to STATA, and I have no clue how to calculate the standard deviation over 3 preceding years. My data looks like this:
Cusip Permno Permco Companyname fyear month........date ......vwreturn
30710 .................................................. 2007 .....1......29/01/2007.......x ..........
30710 .................................................. 2007 .....2......29/02/2007.......x ..........
30710 .................................................. 2007..3/4/5 etc......x...............x ..........
30710 .................................................. 2007 .....12....29/12/2007.......x ..........
30710 .................................................. 2008 .....1......29/01/2008.......x ..........
30710 .................................................. 2007 .....2......29/02/2008.......x ..........
et cetera. I have data from 2007 till 2019, and thousands of unique companies.
From the monthly returns, I already calculated the annual returns (using by cusip fyear: egen yearendret = total(vwreturn). (Then using collapse function) Then my data looks like this:
Cusip Permno Permco Companyname fyear yearendret
30710 .................................................. 2007......x.........
30710 .................................................. 2008......x .........
30710 .................................................. 2009......x..........
30710 .................................................. 2010......x..........
30710 .................................................. 2011......x ..........
Now my question is, how do I calculate the SD for this yearendret?
I already tried: egen sd_yearendret= sd(yearendret), by(cusip fyear)
However, I only get values of 0.
In addition, how do I get the standard deviation of the three preceding years all together? Is it even useful to calculate the SD per year, or is there another way to calculate the SD of yearendret three years prior to t?
Kind regards,
Laura Banken
Related Posts with Computing Standard Deviation of annual returns over three years.
Esttab not giving the right outputHello, I am trying to create a table (4 columns and 3 rows) with names of states (variable state_na…
ivprobit - very high wald chi2 - not the expected signsDear experts, Iam a bit lost in understanding what is going wrong with my model. Here is what I 've…
How to count the number of variables in multiple locals and meanwhile to compute the mean value of each group using for loop in Stata?As the title suggested, I would like to count the number of variables in multiple locals and meanwhi…
Seemingly Unrelated Regression with endogenous variablesCan I use Seemingly Unrelated Regression for system of equations in which I have an institutions var…
Occupation categoization according to STEM definitionHello stata community, I believe I'm having trouble coding the occupation of IPUMS CPS dataset acco…
Subscribe to:
Post Comments (Atom)
0 Response to Computing Standard Deviation of annual returns over three years.
Post a Comment