如题,事件研究法,如果一个公司有多个事件日,该如何写stata程序呢?
对于一个公司只有一个事件日的程序,参考连玉君老师的课件可以如下,如何在此基础上修改呢?
sort companyid date
by companyid: gen datenum = _n
by companyid: gen target = datenum if date==eventdate
egen td = min(target), by(companyid)
gen dif = datenum-td
by companyid: gen event_window=1 if (dif>=-1 & dif<=1)
egen count_event_obs = count(event_window), by(companyid)
by companyid: gen estimation_window=1 if dif<=-2 & dif>=-180
egen count_est_obs=count(estimation_window), by(companyid)
drop if count_event_obs < 3
drop if count_est_obs < 178
replace event_window=0 if event_window==.
replace estimation_window=0 if estimation_window==.
gen predicted_return=.
egen id=group(companyid)
qui tabulate id
local N = r(r)
forvalues i=1(1)`N' {
qui reg ret marketreturn if (id==`i' & estimation_window==1)
predict p if id==`i'
replace predicted_return = p if (id==`i' & event_window==1)
drop p
}
gen abnormal_return = ret - predicted_return if event_window==1
sort id date
by id: egen CAR_id = sum(abnormal_return)
gen CAR_date = .
qui tab id
local N = r(r)
forvalues id = 1(1)`N'{
replace CAR_date = sum(abnormal_return) if (id==`id' & event_window==1)
}


雷达卡





京公网安备 11010802022788号







