凡是搞计量经济的,都关注这个号了
稿件:econometrics666@126.com
所有计量经济圈方法论丛的code程序, 宏微观数据库和各种软件都放在社群里.欢迎到计量经济圈社群交流访问.
今天,展示一下这篇文章的复制数据和代码“那个很早就发AER的中国青年学者, 通过巧秒的空间(地理)断点设计RDD发了(小)JPE!”。有需要的学者,可以自行前往文章主页下载,以便对照着文章进行复制结果,从而掌握RDD的详细操作过程。
*当然也将这些结果完整打包放到了社群里,群友可自行下载。
表格结果及代码:
reg ln_diff_2013_1996 new xcenter ycenter ifdistance<=30,cluster(county) reg ln_diff_2013_1996 new xcenter ycenter ifdistance<=50,cluster(county) reg ln_diff_2013_1996 new xcenter ycenter x2y2 xy if distance<=30,cluster(county) reg ln_diff_2013_1996 new xcenter ycenter x2y2 xy if distance<=50,cluster(county) reg ln_diff_2013_1996 new x3 y3 x2y xy2 x2y2 xy xcenter ycenter,cluster(county) gen x3y=xcenter^3*ycenter gen x2y2=xcenter^2*ycenter^2 gen xy3=xcenter*ycenter^3 reg ln_diff_2013_1996 new x4 x3y x2y2 xy3 y4x3 y3 x2y xy2 x2 y2 xy xcenter ycenter,cluster(county)
reg ln_diff_2013_1996 new xcenter ycenter ifdistance<=30,cluster(county) reg ln_diff_2013_1996 new xcenter ycenter if10<=distance & distance<=30,cluster(county) reg ln_diff_2013_1996 new xcenter ycenter if5<=distance & distance<=30,cluster(county) reg ln_diff_2013_1996 new xcenter ycenter ifdistance<=50,cluster(county) reg ln_diff_2013_1996 new xcenter ycenter if10<=distance & distance<=50,cluster(county) reg ln_diff_2013_1996 new xcenter ycenter if5<=distance & distance<=50,cluster(county)
geodist ycenter xcenter seg01_y seg01_x ,gen(dist_seg01) geodist ycenter xcenter seg02_y seg02_x ,gen(dist_seg02) geodist ycenter xcenter seg03_y seg03_x ,gen(dist_seg03) geodist ycenter xcenter seg11_y seg11_x ,gen(dist_seg11) geodist ycenter xcenter seg12_y seg12_x ,gen(dist_seg12) geodist ycenter xcenter seg13_y seg13_x ,gen(dist_seg13) reg ln_diff_2013_1996 new xcenter ycenter ifdist_seg11<=30 | dist_seg12<=30 |dist_seg13<=30,cluster(county) reg ln_diff_2013_1996 new xcenter ycenter ifdist_seg11<=50 | dist_seg12<=50 |dist_seg13<=50,cluster(county) reg ln_diff_2013_1996 new xcenter ycenter ifdist_seg01<=30 | dist_seg02<=30 |dist_seg03<=30,cluster(county) reg ln_diff_2013_1996 new xcenter ycenter ifdist_seg01<=50 | dist_seg02<=50 |dist_seg03<=50,cluster(county)
******Table 9(Panel A)****** gen l_output_pp=ln(output/popu+0.01) gen urbrate=popu_urb/popu gen nonfarmemploy_ratio=employ_23/popu gen l_road_local_pp=ln(road_local/popu+0.01) genl_road_national_pp=ln(road_national/popu+0.01) gen l_school_pp=ln(school/popu+0.01) gen l_hospital_pp=ln(hospital/popu+0.01) winsor2 l_output_pp if distance<=30, trimcuts(1 99) reg l_output_pp_tr new xcenter ycenter ifdistance<=30,cluster(county) reg urbrate new xcenter ycenter ifdistance<=30,cluster(county) reg nonfarmemploy_ratio new xcenter ycenterif distance<=30,cluster(county) reg l_road_local_pp new xcenter ycenter ifdistance<=30,cluster(county) reg l_road_national_pp new xcenter ycenterif distance<=30,cluster(county) reg l_school_pp new xcenter ycenter ifdistance<=30,cluster(county) reg l_hospital_pp new xcenter ycenter ifdistance<=30,cluster(county)******Table 9(Panel B)****** use data_enterprise.dta,clear bys town: egen num2008_a1997=count(x) if birthyr>=1997 bys town: egencom_2008_a1997=max(num2008_a1997) egen position=concat(xcenter ycenter) duplicates drop position,force merge 1:1 position using"data_si_chong.dta" replace com_2008_a1997=0 if com_2008_a1997==. gen lcom_2008_a1997=ln(com_2008_a1997+0.01) reg lcom_2008 new xcenter ycenter ifdistance<=30,cluster(county) use data_enterprise.dta,clear replace new=1 if province=="重庆市" gen r_prof=profit/salemain winsor2 r_prof ,cuts(0.25 99.75) trim gen industry=int(indcode/100) geodist latq lngq near_cy near_cx ,gen(cdistance) reg r_prof_tr new lngq latq i.industry ifcdistance<=30,cluster(county) use data_cencus2005_30km.dta,clear keep if age>=18 & age<=60 reg water new xcenterycenter,cluster(county) reg nonfarm_emp new xcenterycenter,cluster(county)
reg ln_diff_2013_1996 new xcenter ycenter ifdistance<=30 & inundated==0,cluster(county) reg ln_diff_2013_1996 new xcenter ycenter ifdistance<=50 & inundated==0,cluster(county)
use data_townlight_hubei.dta,clear reg ln_diff_2013_1996 yichang xcenterycenter if distance<=30 reg ln_diff_2013_1996 yichang xcenterycenter if distance<=50 use data_townlight_sichuan.dta,clear reg ln_diff_2013_1996 chengdu xcenterycenter if dist_cdborder<=30,cluster(county) reg ln_diff_2013_1996 chengdu xcenterycenter if dist_cdborder<=50,cluster(county)
图结果及代码:
replace dist_g=-distance if new==0 replace group=-100+(`i'*10) if dist_g>=-100+(`i'*10) &dist_g<-90+(`i'*10) egen distance_mean=mean(dist_g),by(group) egen mean1996_mean=mean(mean1996),by(group) egen elevation_mean=mean(elevation),by(group) egen slope_mean=mean(slope),by(group) gen mean1996_low = mean1996_p - 1.96 * se1 gen mean1996_high = mean1996_p + 1.96 * se1 bygroup, sort : egen float count = count(mean1996_p) twoway (scatter mean1996_mean distance_mean if distance<=100,mcolor(black) ) /* */(line mean1996_p mean1996_low mean1996_high dist_g if dist_g<0 &dist_g>=-100, pstyle(p p3 p3) lcolor(black) lpattern(solid))/* */(line mean1996_p mean1996_low mean1996_high dist_g if dist_g>0 &dist_g<=100, pstyle(p p3 p3) lcolor(black) lpattern(solid)) , /* */ ytitle(Light intensity of 1996) xtitle(Distance to cutoff) legend(off)xline(0,lpattern(dash)) text(1.7 50"Chongqing",size(medlarge)) text(1.7 -50"Sichuan",size(medlarge)) scheme(s1color)
use dynamic_1992-2013,clear graph twoway scatter beta t || line beta t,lcolor(black) || linebeta_low t,lpattern(dash) lcolor(gray) || line beta_high t,lpattern(dash)lcolor(gray) xlabel(1992(2)2013,angle(45)) xtitle(Year),yline(0,lpattern(dash)) xline(1996,lpattern(dash)) legend(off) scheme(s1color) ylabel(-1(0.5)2)
replace dist_g=-distance if new==0 gen group=-100 if distance<=100 replace group=-100+(`i'*10) if dist_g>=-100+(`i'*10) &dist_g<-90+(`i'*10) gen growthrate=ln(mean2013+0.01)-ln(mean1996+0.01) egen growthrate_mean=mean(growthrate),by(group) egen distance_mean=mean(dist_g),by(group) qui reg growthrate new dist_g if distance<=100 gen growthrate_low = growthrate_p - 1.96 * se gen growthrate_high = growthrate_p + 1.96 * se bygroup, sort : egen float count = count(growthrate_p) twoway (scatter growthrate_mean distance_mean if distance<=100,mcolor(black)) /* */(line growthrate_p growthrate_low growthrate_high dist_g if dist_g<0 &dist_g>=-100, pstyle(p p3 p3) lcolor(black) lpattern(solid))/* */(line growthrate_p growthrate_low growthrate_high dist_g if dist_g>0 &dist_g<=100, pstyle(p p3 p3) lcolor(black) lpattern(solid)) , /* */ ytitle(Night light growth rate 1996-2013) xtitle(Distance to cutoff)legend(off) xline(0,lpattern(dash)) text(0.75 50 "Chongqing",size(medlarge)) text(0.75 -50"Sichuan",size(medlarge)) scheme(s1color)
******Figure 6 panel A_Linear****** qui reg ln_diff_2013_1996 new xcenter ycenterif distance<=(`i'+1)*10,cluster(county) scalar A`i'2=sqrt(b`i'[1,1]) mat2txt, matrix(A) saving (matrixa) replace insheet using matrixa.txt,clear graph twoway (rcap low high bw ,lcolor(cranberry) mcolor(midred) msymbol(O) mlabcolor(black))||(scatter coff bw, mcolor(midblue) msymbol(O) mlabcolor(black)) ,yline(0, lpattern(dash)lcolor(black)) legend(off)xtitle("Brandwidth") xlabel(20(10)100) ylabel(-0.5(0.5)2)scheme(s1color)
******Figure 6 panel B_Quadratic****** qui reg ln_diff_2013_1996 new xcenter ycenterx2 y2 xy if distance<=(`i'+1)*10,cluster(county) scalar B`i'2=sqrt(b`i'[1,1]) mat2txt, matrix(B) saving (matrixb) replace insheet using matrixb.txt,clear graph twoway (rcap low high bw ,lcolor(cranberry) mcolor(midred) msymbol(O) mlabcolor(black))||(scatter coff bw, mcolor(midblue) msymbol(O) mlabcolor(black)) ,yline(0, lpattern(dash)lcolor(black)) legend(off)xtitle("Brandwidth") xlabel(20(10)100) ylabel(-0.5(0.5)2)scheme(s1color)
******Figure 6 panel C_Control****** qui reg ln_diff_2013_1996 new xcenter ycenterslope elevation seg1 seg2 seg3 seg4 if distance<=(`i'+1)*10,cluster(county) scalar C`i'2=sqrt(b`i'[1,1]) mat2txt, matrix(C) saving (matrixc) replace insheet using matrixc.txt,clear graph twoway (rcap low high bw ,lcolor(cranberry) mcolor(midred) msymbol(O) mlabcolor(black))||(scatter coff bw, mcolor(midblue) msymbol(O) mlabcolor(black)) ,yline(0,lpattern(dash) lcolor(black)) legend(off) xtitle("Brandwidth") xlabel(20(10)100)ylabel(-0.5(0.5)2) scheme(s1color)
******Figure 6 panel D_Weight****** gen weight`i'=1-distance/(`i'+1)/10 if distance<=(`i'+1)*10 qui reg ln_diff_2013_1996 new xcenter ycenterif distance<=(`i'+1)*10 [weight=weight`i'],cluster(county) scalar D`i'2=sqrt(b`i'[1,1]) mat2txt, matrix(D) saving (matrixd) replace insheet using matrixd.txt,clear graph twoway (rcap low high bw ,lcolor(cranberry) mcolor(midred) msymbol(O) mlabcolor(black))||(scatter coff bw, mcolor(midblue) msymbol(O) mlabcolor(black)) ,yline(0,lpattern(dash) lcolor(black)) legend(off)xtitle("Brandwidth") xlabel(20(10)100) ylabel(-0.5(0.5)2) scheme(s1color) use dynamic_1992-2013_si_gansu,clear graph twoway scatter beta t || line beta t,lcolor(black) || linebeta_low t,lpattern(dash) lcolor(gray) || line beta_high t,lpattern(dash)lcolor(gray) xlabel(1992(2)2013,angle(45)) xtitle(Year),yline(0,lpattern(dash)) xline(1996,lpattern(dash)) legend(off) scheme(s1color) ylabel(-1(1)2) use dynamic_1992-2013_si_guizhou,clear graph twoway scatter beta t || line beta t,lcolor(black) || linebeta_low t,lpattern(dash) lcolor(gray) || line beta_high t,lpattern(dash)lcolor(gray) xlabel(1992(2)2013,angle(45)) xtitle(Year),yline(0,lpattern(dash)) xline(1996,lpattern(dash)) legend(off) scheme(s1color) ylabel(-1(1)2) use dynamic_1992-2013_si_qinghai,clear graph twoway scatter beta t || line beta t,lcolor(black) || linebeta_low t,lpattern(dash) lcolor(gray) || line beta_high t,lpattern(dash)lcolor(gray) xlabel(1992(2)2013,angle(45)) xtitle(Year) ,yline(0,lpattern(dash))xline(1996,lpattern(dash)) legend(off) scheme(s1color) ylabel(-1(1)2) use dynamic_1992-2013_si_shaanxi,clear graph twoway scatter beta t || line beta t,lcolor(black) || linebeta_low t,lpattern(dash) lcolor(gray) || line beta_high t,lpattern(dash)lcolor(gray) xlabel(1992(2)2013,angle(45)) xtitle(Year),yline(0,lpattern(dash)) xline(1996,lpattern(dash)) legend(off) scheme(s1color) ylabel(-1(1)2) use dynamic_1992-2013_si_yunnan,clear graph twoway scatter beta t || line beta t,lcolor(black) || linebeta_low t,lpattern(dash) lcolor(gray) || line beta_high t,lpattern(dash)lcolor(gray) xlabel(1992(2)2013,angle(45)) xtitle(Year),yline(0,lpattern(dash)) xline(1996,lpattern(dash)) legend(off) scheme(s1color) ylabel(-1(1)2)
replace dist_g=-distance if new==0 replace group=-100+(`i'*10) if dist_g>=-100+(`i'*10) &dist_g<-90+(`i'*10) gen l_road_local_pp=ln(road_local/popu*10+1) gen l_road_national_pp=ln(road_national/popu*10+1) gen l_school_pp=ln(school/popu*10+1) gen l_hospital_pp=ln(hospital/popu*10+1) egen distance_mean=mean(dist_g),by(group) egen l_road_local_pp_mean=mean(l_road_local_pp),by(group) egen l_road_national_pp_mean=mean(l_road_national_pp),by(group) egen l_school_pp_mean=mean(l_school_pp),by(group) egen l_hospital_pp_mean=mean(l_hospital_pp),by(group) reg l_road_local_pp new dist_g predict l_road_local_pp_p gen l_road_local_pp_low = l_road_local_pp_p - 1.96 * se1 gen l_road_local_pp_high = l_road_local_pp_p + 1.96 * se1 twoway (scatter l_road_local_pp_mean distance_mean , mcolor(black)) /* */(line l_road_local_pp_p l_road_local_pp_low l_road_local_pp_high dist_g ifdist_g<0, pstyle(p p3 p3) lcolor(black) lpattern(solid))/* */(line l_road_local_pp_p l_road_local_pp_low l_road_local_pp_high dist_g ifdist_g>0, pstyle(p p3 p3) lcolor(black) lpattern(solid)) , /* */ title("Length of local roads per capita") xtitle(Distance tocutoff) legend(off) xline(0,lpattern(dash)) text(1.5 50 "Chongqing",size(med)) text(1.5 -50"Sichuan",size(med)) scheme(s1color) reg l_road_national_pp new dist_g predict l_road_national_pp_p gen l_road_national_pp_low = l_road_national_pp_p - 1.96 * se2 gen l_road_national_pp_high = l_road_national_pp_p + 1.96 * se2 twoway (scatter l_road_national_pp_mean distance_mean , mcolor(black))/* */(line l_road_national_pp_p l_road_national_pp_low l_road_national_pp_highdist_g if dist_g<0, pstyle(p p3 p3) lcolor(black) lpattern(solid))/* */(line l_road_national_pp_p l_road_national_pp_low l_road_national_pp_high dist_gif dist_g>0, pstyle(p p3 p3) lcolor(black) lpattern(solid)) , /* */ title("Length of national roads per capita") xtitle(Distanceto cutoff) legend(off) xline(0,lpattern(dash)) text(0 50 "Chongqing",size(med)) text(0 -50"Sichuan",size(med)) scheme(s1color) reg l_school_pp new dist_g gen l_school_pp_low = l_school_pp_p - 1.96 * se4 gen l_school_pp_high = l_school_pp_p + 1.96 * se4 twoway (scatter l_school_pp_mean distance_mean , mcolor(black) ) /* */(line l_school_pp_p l_school_pp_low l_school_pp_high dist_g if dist_g<0,pstyle(p p3 p3) lcolor(black) lpattern(solid))/* */(line l_school_pp_p l_school_pp_low l_school_pp_high dist_g if dist_g>0,pstyle(p p3 p3) lcolor(black) lpattern(solid)) , /* */ title("Number of schools per capita") xtitle(Distance tocutoff) legend(off) xline(0,lpattern(dash)) text(0.650 "Chongqing",size(med)) text(0.6 -50 "Sichuan",size(med))scheme(s1color) reg l_hospital_pp new dist_g gen l_hospital_pp_low = l_hospital_pp_p - 1.96 * se5 gen l_hospital_pp_high = l_hospital_pp_p + 1.96 * se5 twoway (scatter l_hospital_pp_mean distance_mean , mcolor(black) ) /* */(line l_hospital_pp_p l_hospital_pp_low l_hospital_pp_high dist_g ifdist_g<0, pstyle(p p3 p3) lcolor(black) lpattern(solid))/* */(line l_hospital_pp_p l_hospital_pp_low l_hospital_pp_high dist_g ifdist_g>0, pstyle(p p3 p3) lcolor(black) lpattern(solid)) , /* */ title("Number of hospitals per capita") xtitle(Distance tocutoff) legend(off) xline(0,lpattern(dash)) text(0.5 50 "Chongqing",size(med)) text(0.5 -50"Sichuan",size(med)) scheme(s1color)
usedata_transfer_si_chong.dta,clear twoway (bar trans_p_si year1,barw(0.4)) (bar trans_p_chong year2,barw(0.4)), xlabel(1994(1)2013, angle(45)) xtitle("YEAR")ytitle("Transfer as percentage of GDP(%)") scheme(s1color)
断点回归设计RDD
1.断点回归设计RDD分类与操作案例,2.RDD断点回归, Stata程序百科全书式的宝典,3.断点回归设计的前沿研究现状, RDD,4.断点回归设计什么鬼?且听哈佛客解析,5.断点回归和读者的提问解答,6.断点回归设计RDD全面讲解, 教育领域用者众多,7.没有工具变量、断点和随机冲击,也可以推断归因,8.找不到IV, RD和DID该怎么办? 这有一种备选方法,9.2卷RDD断点回归使用手册, 含Stata和R软件操作流程,10.DID, 合成控制, 匹配, RDD四种方法比较, 适用范围和特征,11.安神+克拉克奖得主的RDD论文, 断点回归设计,12.伊斯兰政府到底对妇女友不友好?RDD经典文献,13.PSM,RDD,Heckman,Panel模型的操作程序,14.RDD经典文献, RDD模型有效性稳健性检验,15.2019年发表在JDE上的有趣文章, 计量方法最新趋势,16.关于(模糊)断点回归设计的100篇精选Articles专辑!17.断点回归设计RDD精辟解释, 保证你一辈子都忘不了,18.“RDD女王”获2020年小诺奖!她的RD数据, 程序, GIS和博士论文可下载!关于她学术研究过程的最全采访!19.中国博导要求掌握的RDD方法实证运用范文(配程序code), 不然就不要用RDD做实证研究!20.最近70篇关于中国环境生态的经济学papers合辑!21.事件研究法用于DID的经典文献"环境规制"论文数据和程序,22.环境, 能源和资源经济学手册推荐, 经典著作需要反复咀嚼,23.中文刊上用断点回归RDD和合成控制法SCM的实证文章有哪些?不看至少需要收藏一下!24.上双一流大学能多赚多少钱? 学习断点回归RDD, 机制分析的经典文章!25.JPE上利用地理断点RDD和IV研究中国环境议题的do文件release!26.中文刊上用断点回归RDD和合成控制法SCM的实证文章有哪些?不看至少需要收藏一下!27.AER上用断点回归设计RDD的实证文章有哪些?含程序和code, 不看至少需要收藏一下!1.合成控制法创始人如何用SCM做实证呢?这些规定动作一个都不能少!2.关于合成控制法SCM的33篇精选Articles专辑!小组惊动了阿里巴巴!3.再谈合成控制法SCM, 帮你寻找因果推断控制组,4.最新: 运用机器学习和合成控制法研究武汉封城对空气污染和健康的影响! 5.合成控制法与HCW方法, 谁能够走得更远?6.广义合成控制法gsynth, Stata运行程序release,7.广义合成控制法gsynth, 基于交互固定效应的因果推断,8.DID, 合成控制, 匹配, RDD四种方法比较, 适用范围和特征,9.合成控制法什么鬼? 因果推断的前沿方法指南,10.用回归控制法HCW(附程序和数据)评估各国经济刺激计划的影响, 真是一个好主意!11.计量院士为你讲解回归控制法HCW的操作, 并配上自己写的一篇范文!12.HCW面板数据政策评估方法, panel数据构造对照组,13.断点回归RD和合成控制法SCM免费课程, 文章, 数据和代码全在这里, 有必要认真研究学习!14.中文刊上用断点回归RDD和合成控制法SCM的实证文章有哪些?不看至少需要收藏一下!下面这些短链接文章属于合集,可以收藏起来阅读,不然以后都找不到了。