mat b =J(500,1,0)
mat se =J(500,1,0)
mat p =J(500,1,0)
forvalues i=1/500{
use "C:\Users\hubin\Desktop\xnlw.dta",clear
xtset id year
keep if year==2008
sample 13,count
keep id
save match_id.dta,replace
merge 1:m id using "C:\Users\hubin\Desktop\xnlw.dta"
gen treated =(_merge==3)
gen period=(year>=2011)
gen DID=period*treated
reghdfe co2 DID $xlist ,absorb(id year) vce(cluster id)
mat b[`i',1]=_b[DID]
mat se[`i',1]=_se[DID]
mat p[`i',1]=2*ttail(e(df_r), abs(_b[DID]/_se[DID]))
}
svmat b,names(coef)
svmat se,names(se)
svmat p,names(pvalue)
drop if pvalue1 == .
label var pvalue1 p值
label var coef1 估计系数
keep coef1 se1 pvalue1
save placebo.dta,replace
use placebo.dta,clear
twoway (kdensity coef1)(scatter pvalue1 coef1,msymbol(smcircle_hollow) mcolor(blue)), ///
title("Placebo Test") ///
xlabel(-0.4(0.1)0.4) ylabel(,angle(0)) ///
xline(-0.171,lwidth(vthin) lp(shortdash)) xtitle("Coefficients") ///
yline(0.1,lwidth(vthin) lp(dash)) ytitle(p value) ///
legend(label(1 "kdensity of estimates") label(2 "p value")) ///
plotregion(style(nome)) ///
graphregion(color(white)) ///
数据我之前发过,在我上个帖子里面,但我不知道怎么再发一遍。