【免费分享】事件研究法市场模型与市场调整模型计算CAR——stata程序代码
产生估计窗口和事件窗口,为了保证观察值数目,要count,果然有,所以删除
use y1.dta,clear
gen es_period=1 if dif>=-100&dif<=-30
gen ev_period=1 if dif>=-5&dif<=5
bysort code:egen obs=count(es_period)
bysort code:egen eobs=count(ev_period)
*先用市场调整法计算ar
gen ar1=ret-mret if ev_period==1
bysort code:gen car1=sum(ar1) if ev_period==1
bysort code:egen car1_11=sum(ar1) if ev_period==1
*用市场模型法计算ar
sort code
egen code1=group(code)
tabstat ret mret if es_period==1,s(n mean sd min max) c(s)
set more off
gen pret=.
forvalues i=1/381{
list code if code1==`i’&dif==0
reg ret mret if code1==`i’&es_period==1
predict p if code1==`i’
replace pret=p if code1==`i’&ev_period==1
drop p
}
gen ar2=ret-pret if ev_period==1
bysort code:egen car2_11=sum(ar2) if ev_period==1
评论前必须登录!
注册