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.
How to do matrix exponential operation in Stata? Code: matrix A = (1,0,0,0,0\0.6,0,.4,0,0\0,.6,0,.4,0\0,0,.6,0,.4\0,0,0,0,1) matrix list A matrix B…
WLS regression using regwls and regressDear All, I have a question regarding WLS regression using Stata commands regwls and regress and wo…
gsem covstructHello. I am running LPA analysis using gsem command. I ve run the analysis in R using the mclust com…
Inverted Normal GraphHello all, Admittedly a mundane question here... I'm simply trying to plot an inverted normal distr…
Generate balance tableHi, I'm trying to replicate this balance table (as in the picture) using some of the example dataset…
Subscribe to:
Post Comments (Atom)
0 Response to Computing Standard Deviation of annual returns over three years.
Post a Comment