Dear Stata comunity,
I need to run month-wise fama and french three factor model regressions using daily data. I have got the following code from one of my friends, but it has some bug. When i run this code, it works only for one stock for one year. Further i require that the code should ignore the stock-month combinations where no of daily returns observation is less than 17.
egen ccode = group(Stock)
egen count_check = count(ccode), by(ccode month year) /* Generate the count of the unique_id combination to check if there are minimum number of observations for the regression */
drop if count_check <=1 /* drops all firm month combinations where the number of trading days is less than 1 */
egen ccode_month_year = group(Stock month year) /* I have groued it by stock month and year so that you can use this code for other years too */
gen resid_reg =. /* Creating a variable to store the residuals */
/* You have to count the number of unique firm_month id... for that you can use the following command */
egen max = max(ccode_month_year)
disp max
/* This will do the regressions and store the residuals in the resid_reg variable */
forvalues i = 1(1)9 {
regress Rt Mkt SMB HML if ccode_month_year==`i'
predict temp , resid
replace resid_reg = temp if ccode_month_year==`i'
drop temp
}
Kindly look into it and advise.
Related Posts with Month-wise regressions using daily data
Different coefficients with XTREG and REGHDFEDear all. My name is Carlos and I am working in a gravity model with 133 countries in a time period…
Eurobarometer and only look at varibles in one countryHi! I have an assignment where I would like to use Eurobarometer. What I want to do is to only look…
convert quartiles to tertilesHello, I am Hatem Ali We summarize the associations corresponding to the top versus bottom third of…
LoopsI have a panel dataset with 26 countries and I want to create the below variables in order to do a t…
Forestplot using the metan commandHi, How can I create a forestplot using the metan command, in which the x range will be from 0.4 to…
Subscribe to:
Post Comments (Atom)
0 Response to Month-wise regressions using daily data
Post a Comment