Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • To compute idiosyncratic and systematic firm risk in Stata

    I am computing idiosyncratic firm risk as a standard deviation of the residuals (errors) of the Fama–French model. I am computing systematic risk by subtracting the squared standard deviation in the errors from the squared standard deviation in returns. I am using the following code in Stata:

    for idiosyncratic risk:

    by id: egen resid_sd=sd(residuals) if id==`i' & estimation_window==1
    replace idiosyncraticrisk =resid_sd if id==`i' & estimation_window==1

    where residuals are generated from the estimation of the Fama-French model, id is the chosen company number and estimation window is the period that was used for estimating the Fama-French model.

    for systematic risk:

    by id: egen resid_sd=sd(residuals) if id==`i' & estimation_window==1
    by id: egen return_sd=sd(return) if id==`i' & estimation_window==1
    replace systematicrisk =(return_sd*return_sd)-(resid_sd*resid_sd) if id==`i' & estimation_window==1

    where return is the return on the stock of company i in a day which is within estimation window.

    Could you please tell me if my code is correct?

    Thanks a lot!
    Maria
Working...
X