egen city= group(cityid)
clear
set matsize 5000
cd"E:\stata-spatial\digitalin-frastructure-finance"
set matsize 5000
mat b = J(500,1,0)
mat se = J(500,1,0)
mat p = J(500,1,0)
forvalues i=1/500{
use "inno_policy.dta", clear
xtset city year
keep if year==2016
sample 96, count
keep city
save "atchcity.dta",replace
merge 1:m city using "inno_policy.dta"
gen groupnew=(_merge==3) //生成伪处理组的虚拟变量
save "matchcity`i'.dta",replace
*伪政策虚拟变量
use "inno_policy.dta",clear
bsample 1, strata(city)
keep year
save "matchyear.dta", replace
mkmat year, matrix(sampleyear)
use "matchcity`i'.dta",replace
xtset city year
gen time = 0
foreach j of numlist 1/269 {
replace time = 1 if (city == `j' & year >= sampleyear[`j',1])
}
gen did1=time*groupnew
global xlist "x1 x2 x3 x4 x5 x6 x7 x8"
xtreg y1 did1 $xlist i.year, fe robust
mat b[`i',1] = _b[did1]
mat se[`i',1] = _se[did1]
scalar df_r = e(N) - e(df_m) -1
mat p[`i',1] = 2*ttail(df_r,abs(_b[did1]/_se[did1]))
}
svmat b, names(coef)
svmat se, names(se)
svmat p, names(pvalue)
drop if pvalue1 == .
label var pvalue1 p值
label var coef1 估计系数
saveplacebo.dta,replace
forvalue i=1/500{
erase "matchcity`i'.dta"
}
twoway(scatter pvaluecoef1,xlabel(-0.015(0.01)0.0155,grid) yline(0.1,lp(shortdash)) xline(1.5,lp(shortdash))xtitle(估计系数) ytitle(p值) msymbol(smcircle_hollow)mcolor(blue) legend(off))(kdensity coef1,title(安慰剂检验))
运行其中出错误的情况
最后图形


雷达卡


京公网安备 11010802022788号







