Hi all,
For the firms in my sample, I need to calculate the volatility of earnings. However, I keep on failing to do this. Measuring volatility can be done by calculating the st. deviations of the last 4 quarters' ROA numbers. So for example, for the following firm it looks like this:
fyearq fqtr cusip conm atq niq ROA
2012 1 55336V100 MPLX LP 1435.2 30.4 .0021182
2012 2 55336V100 MPLX LP 1501.6 29.8 .0198455
2012 3 55336V100 MPLX LP 1250.2 36.9 .0295153
2012 4 55336V100 MPLX LP 1301.3 28.9 .0222086
2013 1 55336V100 MPLX LP 1311.9 17.6 .0134157
2013 2 55336V100 MPLX LP 1217.7 18.6 .0152747
2013 3 55336V100 MPLX LP 1218.7 21.5 .0176417
2013 4 55336V100 MPLX LP 1208.5 20.2 .0167149
2014 1 55336V100 MPLX LP 1193.7 34.2 .0286504
2014 2 55336V100 MPLX LP 1181.4 28.8 .0243779
2014 3 55336V100 MPLX LP 1194.3 29.1 .0243657
2014 4 55336V100 MPLX LP 1214.5 29.2 .0240428
2015 1 55336V100 MPLX LP 1354 68 .0502216
2015 2 55336V100 MPLX LP 1382.6 75 .0542456
2015 3 55336V100 MPLX LP 1391.1 63 .0452879
2015 4 55336V100 MPLX LP 15677 42 .0026791
2016 1 55336V100 MPLX LP 15978 -14 -.0008762
2016 2 55336V100 MPLX LP 16079 71 .0044157
2016 3 55336V100 MPLX LP 16415 192 .0116966
2016 4 55336V100 MPLX LP 16646 183 .0109936
2017 1 55336V100 MPLX LP 18285 186 .0101723
2017 2 55336V100 MPLX LP 18601 190 .0102145
2017 3 55336V100 MPLX LP 19238 216 .0112278
2017 4 55336V100 MPLX LP 19500 238 .0122051
2018 1 55336V100 MPLX LP 21006 421 .0200419
2018 2 55336V100 MPLX LP 21412 453 .0211564
2018 3 55336V100 MPLX LP 22379 510 .0227892
2018 4 55336V100 MPLX LP 22779 434 .0190526
So what I exactly need is:
- One column added that calculates the st. deviation for the 4 quarters every year.
- When I would have this, I need to change the dataset so that I will have one row for every firm-year combination (so that I can merge this with my other dataset).
Hopefully it is clear what I need and what my problems are, and hopefully someone knows which codes/handlings I need to do!
Kind regards
Related Posts with Computing st. deviations per year
Survey pointer to spouse without MataI'm using the IPUMS extract of the CPS March Supplement. In their extract, the variables YEAR, SERIA…
Precision issues with rounding of a variableHello Statalist, I am using Stata 15.1 and would like to request advice regarding a precision issue…
Interaction term as an IV?Hello, I have read a few posts on here that discuss IV when the model has interaction terms, but I …
Interpretation when dependent and independent variables are percentagesDear all, I have a problem with the interpretation of my dependent variables. My dependent variable…
Saving obs with parmest or parmbyHi all, I'm using national survey data to analyze health outcomes for particular population groups.…
Subscribe to:
Post Comments (Atom)
0 Response to Computing st. deviations per year
Post a Comment