Hey community,
i have a dataset with ~900 companies and daily excess return data as well as the smb, hml and mom factor from the Carhart Modell. Now i need to calculate the idiosyncratic risk which is the annualized standard deviation of the residuals. Here is my code for one company, however this gives me the same standard deviation for all ~250 trading days with different values per year. I need to run the regression for every company in my sample (u_s_1 - u_s_913) but just to demonstrate here is my code for 1 company.
Can somebody help me correcting the code?
Best regards, Patrick
i have a dataset with ~900 companies and daily excess return data as well as the smb, hml and mom factor from the Carhart Modell. Now i need to calculate the idiosyncratic risk which is the annualized standard deviation of the residuals. Here is my code for one company, however this gives me the same standard deviation for all ~250 trading days with different values per year. I need to run the regression for every company in my sample (u_s_1 - u_s_913) but just to demonstrate here is my code for 1 company.
Code:
regress u_s_1 smb hml mom u_i_sp500composite if year == 2002 predict resid egen yearly_sd_resid = sd(resid), by(year)
Best regards, Patrick
Comment