仅供参考~~
Step 1: Cleaning the data and Calculating the Event and Estimation Windows
cd c:\stata14\data\实证公司金融作业
use "repurchase class",clear
joinby gvkey using "crsp daily 07-09 new ret"
sort gvkey InitialAuthDate datadate
by gvkey InitialAuthDate: gen datenum=_n
by gvkey InitialAuthDate: gen target= datenum if datadate== InitialAuthDate
by gvkey InitialAuthDate: egen td=min(target)
label variable td "by gvkey InitialAuthDate: egen td=min(target)"
gen dif= datenum-td
by gvkey InitialAuthDate: gen estimation_window=1 if dif<-150 & dif>=-250
label variable estimation_window"by gvkey: gen estimation_window=1 if dif<-150 & dif>=-250"
replace estimation_window=0 if estimation_window==.
by gvkey InitialAuthDate: gen event_window=1 if dif>=-1 & dif<=1
label variable event_window"by gvkey: gen event_window=1 if dif>=-1 & dif<=1"
replace event_window=0 if event_window==.
by gvkey InitialAuthDate, sort: egen max_event_window=max( event_window)
count if max_event_window==0
drop if max_event_window==0
by gvkey InitialAuthDate, sort: egen max_est_window=max( estimation_window)
count if max_est_window==0
drop if max_est_window==0
count if target!=.
save "c:\stata14\data\实证公司金融作业\event_study_repurchase_class.dta"
merge m:1 datadate using "c:\stata14\data\实证公司金融作业\mkt index small.dta"
drop if _merge==2
rename _merge merge_mkt_index
sort gvkey InitialAuth datadate
Step 2: Estimating Normal Performance
egen id=group(gvkey InitialAuthDate)
gen pre_ret=.
drop if event_window==0 & estimation_window==0
forvalues i=1(1)797 {
qui reg ret vwretd if id==`i' & estimation_window==1
qui predict p if id==`i'
qui replace pre_ret=p if id==`i' & event_window==1
drop p
}
Step 3: Abnormal and Cumulative Abnormal Returns
gen abn_ret= ret-pre_ret if event_window==1
sort id datadate
by id: egen cum_abn_ret=sum( abn_ret) if event_window==1
label variable pre_ret"predicted value from market model"
label variable abn_ret"= ret-pre_ret if event_window==1"
label variable cum_abn_ret"by id: egencum_abn_ret=sum( abn_ret) if event_window==1"
Step 4:Testing for Significance
ttest cum_abn_ret=0
reg cum_abn_ret, robust