Hello!
My name is Julien and I am a Finance master student. I have been trying for a while now to construct some loops yet I keep running into some issues in the preparation.
My main question is;
how can I create loops to measure the effect of earnings announcements of peer firms by industry and subindustry?
My code for this currently looks as following;
expand `Distance'
bys firmid eventdate: gen int tau=_n + `Estimationwindowstart' -1
assert(tau<=`Eventwindowend')
* creating eventid *
egen eventid = group(industrycode eventdate)
egen eventid2 = group(industrycode subindustrycode eventdate)
*generate real dates*
gen date = eventdate+tau
format date %tbtrdates
* loop 1 using eventid 1 *
rangestat (reg) ret mktrt if tau<=`Estimationwindowend', by(eventid) interval(tau . .)
bys eventid: egen cons_coeff=mean(b_cons)
bys eventid: egen mktrt_coeff=mean(b_mktrt)
gen NR10 = cons_coeff + mktrt_coeff*mktrt
drop if NR10==.
drop cons_coeff
drop mktrt_coeff
drop reg_nobs reg_r2 reg_adj_r2 b_mktrt b_cons se_mktrt se_cons
gen AR10 = ret - NR10
However I think I have made a mistake with the eventid(s) and that I need to do something else. Moreover I am currently looking at the effect of announcements of the firm itself, while I want to look at the effect of the announcements of peer firms. I am thus thinking of maybe something like including factor dummy variables into the loop, yet I haven't been able to do that as Stata gave me the error; factor-variable operators not allowed.
I'll gladly hear from you what you think is best and what tips and advice you may have,
Thank you in advance;
Kind regards, Julien Maas.
My name is Julien and I am a Finance master student. I have been trying for a while now to construct some loops yet I keep running into some issues in the preparation.
My main question is;
how can I create loops to measure the effect of earnings announcements of peer firms by industry and subindustry?
My code for this currently looks as following;
expand `Distance'
bys firmid eventdate: gen int tau=_n + `Estimationwindowstart' -1
assert(tau<=`Eventwindowend')
* creating eventid *
egen eventid = group(industrycode eventdate)
egen eventid2 = group(industrycode subindustrycode eventdate)
*generate real dates*
gen date = eventdate+tau
format date %tbtrdates
* loop 1 using eventid 1 *
rangestat (reg) ret mktrt if tau<=`Estimationwindowend', by(eventid) interval(tau . .)
bys eventid: egen cons_coeff=mean(b_cons)
bys eventid: egen mktrt_coeff=mean(b_mktrt)
gen NR10 = cons_coeff + mktrt_coeff*mktrt
drop if NR10==.
drop cons_coeff
drop mktrt_coeff
drop reg_nobs reg_r2 reg_adj_r2 b_mktrt b_cons se_mktrt se_cons
gen AR10 = ret - NR10
However I think I have made a mistake with the eventid(s) and that I need to do something else. Moreover I am currently looking at the effect of announcements of the firm itself, while I want to look at the effect of the announcements of peer firms. I am thus thinking of maybe something like including factor dummy variables into the loop, yet I haven't been able to do that as Stata gave me the error; factor-variable operators not allowed.
I'll gladly hear from you what you think is best and what tips and advice you may have,
Thank you in advance;
Kind regards, Julien Maas.
Comment