我研究的是政策对企业的影响,数据是企业层面和城市层面相结合,3175个企业10年的数据,企业所在地有334个城市,其中有59个处理组城市,在进行多期did安慰剂检验中,运行到 mkmat year,matrix(sampleyear)的命令时出现invalid syntax的错误提示,请问改怎么处理呢?代码如下:
mat b=J(500,1,0)
mat se=J(500,1,0)
mat p=J(500,1,0) //构造矩阵
forvalues i=1/500{
use "D:\论文资料\workingdata\员工数据.dta", clear
xtset stock_code year
bsample 1, strata(城市代码)
sample 59,count
keep 城市代码
save matchcity.dta, replace
merge 1:m 城市代码 using "D:\论文资料\workingdata\员工数据.dta"
gen treat1=(_merge==3)
save matchcity`i'.dta,replace
use "D:\论文资料\workingdata\员工数据.dta", clear
bsample 1,strata(城市代码)
keep year
save matchyear.dta,replace
mkmat year,matrix(sampleyear)
use matchcity`i'.dta,replace
xtset stock_code year
gen time1=0
forval j of numlist 1/3175{
replace time1=1 if(城市代码==`j'&year>=sampleyear[`j',1])
}
gen did1=time1*treat1
qui xtreg LS did1 Size FIXED Mfee TobinQ foreign_investment human_captial i.year,fe cluster(city) nonest
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]))
}


雷达卡


京公网安备 11010802022788号







