其他
第4篇DID“学术新星”新方法__23年第7期《数量经济技术经济研究》上DID安慰剂检验方法_一行代码随机抽样500/1000次
第4篇DID“学术新星”新方法__2023年第7期《数量经济技术经济研究》上最新DID安慰剂检验方法_一行代码随机抽样500/1000次
前沿_2023年第7期《数量经济技术经济研究》上合成DID、DIDm+csdid估计量等DID前沿主题文章 (qq.com)
第3篇DID学术“新星”_2023年第7期《数量经济技术经济研究》上最新DID安慰剂检验方法_一行代码随机抽样500/1000次 (qq.com)
DID安慰剂检验方法大全(14+种)+推荐2023年第7期《数量经济技术经济研究》上DID主题文章 (qq.com)
前沿推荐_2023年第7期《数量经济技术经济研究》上动态合成双重差分文章操作及应用 (qq.com)
今天给大家推荐一篇期刊论文的do文档,这估计是小编看到的截止目前最清楚明白的do文档了。
该论文方法及检验方法如下:
DID模型 变量的平行趋势假设检验 反事实分析--置换检验--随机抽样500次 联合固定效应模型 处理效应模型 预期效应检验 三重差分模型排除其他干扰性因素的影响 PSM-DID
该论文do文档模板特点
1、 直接将相关描述分析及回归分析结果展现到do文档里面,能够清楚的与论文原文表格对应起来
2、做的相关检验在do文档里面介绍的也很清晰
3、使用最新的permute命令进行安慰剂检验,这是之前公众号重磅推荐的学术新方法
下面跟着小编一起来看看这篇论文do文档精彩片段
1、permute命令进行安慰剂检验方法命令
*- 1. 安慰剂检验
preserve
permute did b = _b[did] t = _b[did]/_se[did], reps(500) seed(12345) ///
saving("$temp_path/simu_po.dta", replace): ///
qui reghdfe polint1 did $ctrlist trend, $regopt
permute did b = _b[did] t = _b[did]/_se[did], reps(500) seed(12345) ///
saving("$temp_path/simu_op.dta", replace): ///
qui reghdfe tfp_op did $ctrlist trend, $regopt
** 被解释变量为polint1
use $temp_path/simu_po.dta, clear
qui sum b, detail
#d ;
dpplot b,
xline(`r(mean)', lpattern(solid) lcolor(red) lwidth(medium))
//xline(-0.477 , lpattern(solid) lcolor(black))
scheme(qleanmono)
msy(smcircle_hollow) mcolor(black)
xtitle("{stSans:系数}" , size(large) margin(zero))
ytitle("{stSans:密}""{stSans:度}", size(large) margin(zero) orientation(h))
saving("$temp_path/Placebo Test of polint1", replace)
xlabel(-0.02(0.01)0.02 0.00 "0", labsize(large) format(%6.2f) tp(i) tlw(medium))
ylabel( , labsize(large) format(%6.0f) tp(i) tlw(medium))
xscale(lwidth(medium)) yscale(lwidth(medium))
line(lcolor(black) lwidth(medium))
caption("") graphregion(margin(medsmall))
;
#d cr
graph export "$temp_path/Placebo Test of polint1.emf", replace
** 被解释变量为tfp_op
use $temp_path/simu_op.dta, clear
qui sum b, detail
#d ;
dpplot b,
xline(`r(mean)', lpattern(solid) lcolor(red) lwidth(medium))
//xline(-0.079 , lpattern(solid) lcolor(black))
scheme(qleanmono)
msy(smcircle_hollow) mcolor(black)
xtitle("{stSans:系数}" , size(large) margin(zero))
ytitle("{stSans:密}""{stSans:度}", size(large) margin(zero) orientation(h))
saving("$temp_path/Placebo Test of tfp_op", replace)
xlabel(-0.02(0.01)0.02 0.00 "0", labsize(large) format(%6.2f) tp(i) tlw(medium))
ylabel( , labsize(large) format(%6.0f) tp(i) tlw(medium))
xscale(lwidth(medium)) yscale(lwidth(medium))
line(lcolor(black) lwidth(medium))
caption("") graphregion(margin(medsmall))
;
#d cr
graph export "$temp_path/Placebo Test of tfp_op.emf", replace
restore
eststo clear
2、回归结果以及展现
if `k2' == 1 {
**# 基准回归
use $path/gqwr.dta, clear
xtset idcode year
gen did = treat * [year >= 2007]
replace did = treat * 0.42 if 2007.year
preserve
** 污染防治成效
eststo m11: qui reghdfe polint1 did, $regopt
eststo m12: qui reghdfe polint1 did $ctrlist trend, $regopt
eststo m13: qui reghdfe polint2 did $ctrlist trend, $regopt
eststo m14: qui reghdfe polint3 did $ctrlist trend, $regopt
** 全要素生产率
eststo m21: qui reghdfe tfp_op did, $regopt
eststo m22: qui reghdfe tfp_op did $ctrlist trend, $regopt
eststo m23: qui reghdfe tfp_lp did $ctrlist trend, $regopt
loc fe idcode "id fe" year "year fe" ///
indcode2 "ind fe" areacode2 "city fe"
estfe m??, labels(`fe')
#d ;
esttab m??, replace nogap nocon b(%9.4f) se(%9.4f) ar2(%9.4f)
indicate("ctrlvars = $ctrlist" "trend = trend" `r(indicate_fe)')
;
#d cr
restore
eststo clear
}
/*
----------------------------------------------------------------------------------------------------------------------------
(1) (2) (3) (4) (5) (6) (7)
polint1 polint1 polint2 polint3 tfp_op tfp_op tfp_lp
----------------------------------------------------------------------------------------------------------------------------
did -0.4751*** -0.4772*** -1.2537*** -0.3361*** -0.0915*** -0.0793*** -0.0547***
(0.0315) (0.0313) (0.1075) (0.0711) (0.0212) (0.0191) (0.0130)
ctrlvars No Yes Yes Yes No Yes Yes
trend No Yes Yes Yes No Yes Yes
id fe Yes Yes Yes Yes Yes Yes Yes
year fe Yes Yes Yes Yes Yes Yes Yes
ind fe Yes Yes Yes Yes Yes Yes Yes
city fe Yes Yes Yes Yes Yes Yes Yes
----------------------------------------------------------------------------------------------------------------------------
N 249504 249504 249504 249504 249504 249504 249504
adj. R-sq 0.6705 0.6729 0.6502 0.7235 0.7089 0.7573 0.8473
----------------------------------------------------------------------------------------------------------------------------
Standard errors in parentheses
* p<0.05, ** p<0.01, *** p<0.001
*/
3、平行趋势检验
if `k3' == 1 {
**# 平行趋势检验
use $path/gqwr.dta, clear
graph set window fontface "Times New Roman"
graph set window fontfacesans "宋体"
preserve
gen current = 2007.year * treat * 0.42
forv i = 11 / 13 {
replace year = year - 1 if 20`i'.year
}
gen before6 = [1998.year | 1999.year | 2000.year | 2001.year] * treat
forv i = 5(-1)1 {
gen before`i' = [year == 2007 - `i'] * treat
}
forv i = 1 / 5 {
gen after`i' = [year == 2007 + `i'] * treat
}
drop before1
set l 99
** 被解释变量为polint1
qui reghdfe polint1 before? current after? $ctrlist trend, $regopt
gen a = (_b[before6] + _b[before5] + _b[before4] + _b[before3] + _b[before2]) / 5
qui sum a
#d ;
coefplot, keep(before? current after?)
vert trans(*=@-r(mean))
scheme(qleanmono)
coeflabels(before6 = 98-01 before5 = 2002 before4 = 2003 before3 = 2004 before2 = 2005
current = 2007 after1 = 2008 after2 = 2009 after3 = 2011
after4 = 2012 after5 = 2013)
msymbol(O) msize(medlarge) mcolor(black)
addplot(line @b @at, lcolor(black) lwidth(thick) lpattern(solid))
ciopts(recast(rarea) fcolor(gs0%18) lwidth(none))
yline(0, lpattern(solid) lcolor(red) lwidth(medium))
xline(6, lpattern(solid) lcolor(black) lwidth(medium))
ytitle("{stSans:系}""{stSans:数}", size(large) orientation(h))
xtitle("{stSans:年份}" , size(large))
xlabel( , labsize(large) tp(i) tlw(medium))
ylabel(-0.8(0.2)0.2 0.0 "0", labsize(large) tp(i) tlw(medium) format(%2.1f))
xsize(7) ysize(4)
xscale(lwidth(medium)) yscale(lwidth(medium))
graphregion(margin(medsmall))
saving("$temp_path/Event Study of polint1", replace)
;
#d cr
cap gr export "$temp_path/Event Study of polint1.emf", replace
** 被解释变量为tfp_op
qui reghdfe tfp_op before? current after? $ctrlist trend, $regopt
gen b = (_b[before6] + _b[before5] + _b[before4] + _b[before3] + _b[before2]) / 5
qui sum b
#d ;
coefplot, keep(before? current after?)
vert trans(*=@-r(mean))
scheme(qleanmono)
coeflabels(before6 = 98-01 before5 = 2002 before4 = 2003 before3 = 2004 before2 = 2005
current = 2007 after1 = 2008 after2 = 2009 after3 = 2011
after4 = 2012 after5 = 2013)
msymbol(O) msize(medlarge) mcolor(black)
addplot(line @b @at, lcolor(black) lwidth(thick) lpattern(solid))
ciopts(recast(rarea) fcolor(gs0%18) lwidth(none))
yline(0, lpattern(solid) lcolor(red) lwidth(medium))
xline(6, lpattern(solid) lcolor(black) lwidth(medium))
ytitle("{stSans:系}""{stSans:数}", size(large) orientation(h))
xtitle("{stSans:年份}" , size(large))
xlabel( , labsize(large) tp(i) tlw(medium))
ylabel(-0.3(0.1)0.2 0.0 "0", labsize(large) tp(i) tlw(medium) format(%2.1f))
xsize(7) ysize(4)
xscale(lwidth(medium)) yscale(lwidth(medium))
graphregion(margin(medsmall))
saving("$temp_path/Event Study of tfp_op", replace)
;
#d cr
cap gr export "$temp_path/Event Study of tfp_op.emf", replace
restore
eststo clear
}
4、PSM-DID
*- 4. 利用PSM-DID方法解决由可观测因素带来的基准回归自选择问题
tab treat
preserve
duplicates drop idcode, force
tab treat
restore
drop openyear output va asset fixasset ///
curdepr curasset debt pay vat capital ///
income cost interinput finexp profit itp ///
wastwater cheoxygen sudioxide employee nprofit
forv i = 1998 / 2013 {
preserve
cap {
keep if `i'.year
qui psmatch2 treat $ctrlist, logit n(2) ties com ate cal(0.01)
save $temp_path/`i'.dta, replace
}
restore
}
use $temp_path/1998.dta, clear
forv k = 1999 / 2013 {
cap {
app using $temp_path/`k'.dta
erase $temp_path/`k'.dta
}
}
gen weight = _weight * 2
replace weight = int(weight)
qui reghdfe polint1 did $ctrlist trend if !mi(_weight), $regopt
est sto m11
qui reghdfe tfp_op did $ctrlist trend if !mi(_weight), $regopt
est sto m12
qui reghdfe polint1 did $ctrlist trend [fw = weight], $regopt
est sto m21
qui reghdfe tfp_op did $ctrlist trend [fw = weight], $regopt
est sto m22
esttab m??, nogap nocon b(%9.4f) se(%9.4f) ar2(%9.4f)
erase $temp_path/1998.dta
eststo clear
/*
----------------------------------------------------------------------------
(1) (2) (3) (4)
polint1 tfp_op polint1 tfp_op
----------------------------------------------------------------------------
did -0.4750*** -0.0489* -0.3750*** -0.0637**
(0.0376) (0.0247) (0.0296) (0.0207)
age 0.0022 -0.0022* 0.0020 -0.0045***
(0.0016) (0.0010) (0.0019) (0.0011)
size1 -0.1628*** 0.4333*** -0.2056*** 0.4555***
(0.0170) (0.0118) (0.0198) (0.0135)
size2 0.0093 0.1216*** 0.0395 0.1227***
(0.0187) (0.0130) (0.0227) (0.0147)
capstr -0.0956 -0.5049*** -0.0388 -0.4573***
(0.0492) (0.0315) (0.0573) (0.0329)
leverage -0.0017 -0.2149*** 0.0315 -0.1807***
(0.0407) (0.0272) (0.0453) (0.0299)
roa -0.4813*** 2.0723*** -0.5662*** 2.1563***
(0.0520) (0.0386) (0.0549) (0.0441)
wage 0.0001 0.0048*** 0.0003 0.0043***
(0.0002) (0.0002) (0.0003) (0.0002)
growth -0.1460*** 0.2418*** -0.1965*** 0.2240***
(0.0130) (0.0091) (0.0150) (0.0099)
trend 0.0106 0.0484*** 0.0285* 0.0437***
(0.0116) (0.0079) (0.0142) (0.0093)
----------------------------------------------------------------------------
N 126476 126476 498340 498340
adj. R-sq 0.6215 0.7289 0.7784 0.8442
----------------------------------------------------------------------------
Standard errors in parentheses
* p<0.05, ** p<0.01, *** p<0.001
*/
更多内容阅读原文