老师,您好,连续事件的did使用ddid方法,但是我不太明白stata自带help文件举例这个方法。能帮忙解读一下吗?
clear
set obs 5
set seed 10101
gen id=_n
expand 50
drop in 1/5
bys id: gen time=_n+1999
gen D=rbinomial(1,0.4)
gen x1=rnormal(1,7)
tsset id time
forvalues i=1/6{
gen L`i'_x=L`i'.x
}
bys id: gen y0=5+1*x+ rnormal()
bys id: gen y1=100+5*x+90*L1_x+90*L2_x+120*L3_x+100*L4_x+90*L5_x +90*L6_x + rnormal()
gen A=6*x+rnormal()
replace D=1 if A>=15 // 为什么是15?
replace D=0 if A<15
gen y=y0+D*(y1-y0)
tsset id time
xi: ddid y D x , model(fe) pre(6) post(6) vce(robust) graph save_graph(mygraph)
|