DID专题一:标准两期DID研究框架基础详解香港股票 杠杆
明天和后天分别更新python和R的实现代码。
二、政策背景2.1政策发布及政策演变过程2012年7月,青岛发布《关于建立长期医疗护理保险制度的意见(试行)》,其中规定在城镇开始施行长护险制度,到2015年将这长护险制度扩展到农村地区。这里我们可以注意到两个关键时间点2012年和2015年。
2.2青岛长护险制度试点的参保对象参加城镇职工医疗保险、城乡居民医疗保险的参保人统一纳入长护险。
2.3享受长护险待遇的标准参保人因年老、疾病、伤残等原因长年卧床已达或预期达到6个月以上病情基本稳定,按照《日常生活能力评定量表》评定低于60分2.4长护险制度提供的待遇2.4.1 四种照护医疗专护:二级及以上住院定点医疗机构医疗专护病房为参保人提供长期24小时连续医疗服务护理院医疗护理(院护):医养结合的护理服务机构为入住本机构的参保人提供24小时连续医疗护理服务居家医疗服务(家护):护理服务机构派医护人员到参保职工家中提供医疗护理服务社区巡护(巡护),护理服务机构(含村卫生室)派医护人员到参保人家中提供服务2.4.2 保险符合规定的医疗护理费用三、数据说明原论文采用了2011、2013、2015三期的调查数据。我们本次主要介绍标准两期DID的应用,所以只采用2011和2015两期的数据。数据样本为45岁以上中老年人家庭和个人,具体内容包含家庭特征、人口统计学特征、个人和家庭经济状况、健康状况、医疗服务利用及其花费、生活习惯、疾病史等。
四、模型设置4.1 控制组和政策实行前后在DID方法的模型设置中,最为重要的两个变量设置是:
分清实验组和控制组,即受到政策干预的样本和不受政策影响的样本,依据政策背景可知,实验组样本为调查数据中的青岛的城镇中老年居民,控制组为调查数据中的其它城市的城镇居民;
分清政策实施的先后。依据政策背景可知,政策在2012年开始实行,由于本次我们仅介绍标准两期DID方法的应用,因此2011年数据为长护险制度实行前的样本数据,2015年调查数据为制度实行之后的样本数据。
4.2 结果变量结果变量本文依据论文的设置,包含以下指标:过去一个月门诊消费总量、过去一个月门诊就诊次数、过去一年住院消费总额、过去一年住院次数。
4.3 控制变量同样参照论文,我们考虑了年龄、性别、婚姻状况等人口学变量;教育、家庭人均收入等社会经济地位变量;自评健康、慢性病患病数量等健康水平变量。并且通过控制。
图片
最终得到以下回归模型:
式(1)中,bi表示城市,表示样本个体,表示时间,为因变量具体回归中依次替换为表1中的四个因变量,为控制变量,为随机扰动项,为核心回归参数,表示在青岛城市居民中实施的长护险制度的政策效应。
五、利用stata实现数据分析==获取分析数据关注公众号并回复:长护险DID分析==
5.1 安装外部命令包ttable用于分组T检验,winsor2用于缩尾或者截尾,logout用于输出统计结果到word/excel,sum2docx用于输出描述性统计分析到word,diff用于DID分析,reghdfe用于高维固定效应回归,ftools是基于mata语言的套件(正常运行reghdfe所需的外部包)。
ssc install ttable2 , replace ssc install winsor2 , replace ssc install logout , replace ssc install sum2docx , replace ssc install diff , replacessc install reghdfe , replace ssc install ftools, replace以上的每一行code运行成功后会显示如下内容(****依次为ttable2 winsor2 logout sum2docx)
checking **** consistency and verifying not already installed...all files already exist and are up to date.
在国内有时运行很慢或者安装不成功,这是可以先运行以下代码:
ssc install cnssc , replace之后再运行以下代码:
cnssc install ttable2 , replace cnssc install winsor2 , replace cnssc install logout , replace cnssc install sum2docx , replacecnssc install diff , replace cnssc install ftools, replace5.2 描述性统计分析
首先规定工作路径(例如数据位于E盘project文件夹,分析结果也集中放在此文件夹),导入数据并对数据进行缩尾处理(去除极端值)。
cd 'E:\project' //设定工作路径use final.dta , clear //导入dta格式数据foreach var in cost_clinic time_clinic cost_hos time_hos Post Treat DID Rural Age Gender married Edu_Group fainc lnfainc chro gh pain cesd{ drop if `var'==.} //删除任意变量有缺失值的样本winsor2 cost_clinic time_clinic cost_hos time_hos Age chro Edu_Group fainc lnfainc gh cesd,cut(1 99) replace //对所有连续变量以及多值定序分类变量进行1%和99%的缩尾处理删除任一有缺失值的样本是采用foreach循环实现,'vat'表示循环指针,'in'到'{’之间的变量表示需要参与循环的变量,'{}’之中是进行样本删除的代码。
winsor2命令后是需要进行winsorize处理的变量;','后(option部分),cut(1 99)表示缩尾的节点为1%分位数和99%分位数,小于1%分位数的值全部改变为1%分位数的值,其含义为变量中大于99%分位数的值全部改变为99%分位数的值。replace表示缩尾后的变量替换原变量,不加replace表示生成的winsorize处理后的变量其变量名带有后缀'_w'。
5.2.1 进行全样本的描述性统计分析tabstat cost_clinic time_clinic cost_hos time_hos Post Treat DID Rural Age Gender married Edu_Group fainc lnfainc chro gh pain cesd,s(n mean sd cv min median max k sk) c(s)tabstat表示对紧跟其后的一系列变量进行描述性统计分析,','后(option部分)的's()'中表述需要计算的统计量,'c(s)'表示统计量按例摆放(若为'c(v)'则表示按列摆放的为变量,即下面的结果将进行转置)。
得到描述性统计结果:
Variable | N Mean SD CV Min p50 Max Kurtosis Skewness-------------+------------------------------------------------------------------------------------------ cost_clinic | 29391 120.0818 518.2586 4.31588 0 0 4000 41.89921 6.052325 time_clinic | 29391 .3545303 .9212584 2.598532 0 0 5 14.01949 3.235013 cost_hos | 29391 725.6395 3311.203 4.563151 0 0 25000 37.96861 5.737651 time_hos | 29391 .1069715 .3766619 3.521141 0 0 2 16.70562 3.728614 Post | 29391 .5180838 .4996814 .9644799 0 1 1 1.005239 -.0723824 Treat | 29391 .0038787 .0621597 16.02575 0 0 1 255.8197 15.96307 DID | 29391 .0022116 .046976 21.24111 0 0 1 450.1714 21.19367 Rural | 29391 .7937124 .4046463 .5098148 0 1 1 3.107502 -1.451724 Age | 29391 59.19077 9.369093 .1582864 45 58 83 2.485779 .4759141 Gender | 29391 .5103263 .4999019 .979573 0 1 1 1.001707 -.041314 married | 29391 .8776156 .3277348 .3734378 0 1 1 6.310427 -2.304436 Edu_Group | 29391 2.938689 1.338308 .45541 1 3 5 1.873939 -.112724 fainc | 29391 12178.41 15801.98 1.297541 1 6766 93714.33 11.91505 2.663377 lnfainc | 29391 8.155491 2.527126 .3098681 .6931472 8.819813 11.44802 6.145089 -1.879134 chro | 29391 1.488483 1.456642 .9786083 0 1 6 3.607613 1.028399 gh | 29391 2.156204 .5803246 .2691418 1 2 3 2.774461 -.0277315 pain | 29391 .2998537 .4582015 1.528083 0 0 1 1.763233 .8736319 cesd | 29391 8.079378 6.284093 .7777941 0 7 26 3.078649 .8498227--------------------------------------------------------------------------------------------------------
第一种导出方法,利用'logout':
接下来将描述性统计分析结果输出到word(table1c_descrip_all.rtf):'logout'为导出统计表格的命令,主体部分在','后(option部分)。'save()'部分指定统计表格导出的文件夹路径和文件名(不加文件路径则导出到工作路径),'word'表示导出文件格式为rtf,'replace'若导出的文件夹已存在同名文件则替换已存在的文件;':'后为需要导出的表格,我们这里需要是描述性统计分析的命令,因此导出的表格是描述性统计分析结果。
logout,save(table1c_descrip_all) word replace:tabstat cost_clinic time_clinic cost_hos time_hos Post Treat DID Rural Age Gender married Edu_Group fainc lnfainc chro gh pain cesd,s(n mean sd cv min median max k sk) c(s)第二种输出方法,使用sum2docx命令:
'sum2docx'与'logout'不同,不会在stata的结果窗口生成描述性统计分汇报表,而是直接将结果导出到word。需要进行描述性统计分析的变量放在'sum2docx'之后,'using'之后输入导出的文件夹路径和文件名,'stats()'中指定需要输出的统计量,replace的含义与上面相同。
sum2docx cost_clinic time_clinic cost_hos time_hos Post Treat DID Rural Age Gender married Edu_Group fainc lnfainc chro gh pain cesd using 'table1c_descrip_all.docx', replace stats(N mean sd min p25 median p75 max skewness kurtosis)5.2.2 进行分组对比分析
描述性统计分析是对各变量的分布情况,样本间差异情况的一个总体说明,我们需要进一步检验控制组和实验组在政策实行前后的各变量进行对比。
控制组长护险制度实行前后的结果变量对比:
'ttable2'为进行t检验的命令,后紧跟需要进行t检验的变量。'if Treat==0'表示仅对控制组样本进行T检验分析。逗号后的'by(Post)'表示按照政策实行前后进行对比检验,'format'规定均值和均值差异的数值格式为保留小数点后4位小数。
ttable2 cost_clinic time_clinic cost_hos time_hos Age Gender married Edu_Group fainc chro gh pain cesd if Treat==0 , by(Post) format(%9.4f)下表为T检验结果表,' G(0)'和'Mean1'分别表示政策实施前的样本量和均值,' G(1)'和'Mean2'分别表示政策实施后的样本量和均值,'MeanDiff'为均值差异。'*'、'**'和'***'分别表示在0.1、0.05、0.01的水平通过显著性检验。
--------------------------------------------------------------------------Variables G1(0) Mean1 G2(1) Mean2 MeanDiff--------------------------------------------------------------------------cost_clinic 14115 92.5326 15162 146.1172 -53.5846***time_clinic 14115 0.3544 15162 0.3561 -0.0016cost_hos 14115 464.8485 15162 962.3160 -497.4675***time_hos 14115 0.0808 15162 0.1308 -0.0500***Age 14115 58.7795 15162 59.5625 -0.7830***Gender 14115 0.5173 15162 0.5036 0.0136**married 14115 0.8748 15162 0.8804 -0.0055Edu_Group 14115 2.7601 15162 3.1027 -0.3426***fainc 14115 1.22e+04 15162 1.20e+04 138.3820chro 14115 1.3852 15162 1.5863 -0.2011***gh 14115 2.2072 15162 2.1103 0.0969***pain 14115 0.3170 15162 0.2843 0.0326***cesd 14115 8.3514 15162 7.8504 0.5010***--------------------------------------------------------------------------
从上表可知,在政策实施之后,控制组样本的门诊花费(cost_clinic)、住院花费(time_clinic)、住院次数(time_hos)均有显著的增加,分别增加了53.5846元、497.467元和0.05次。
控制组政策前后对比结果输出到word,文件名为table1b_descrip_treat:语法说明与前文一致,不再论述。
logout, save(table1b_descrip_treat) word replace:ttable2 cost_clinic time_clinic cost_hos time_hos Age Gender married Edu_Group fainc chro gh pain cesd if Treat==0 , by(Post) format(%9.4f)实验组(青岛市)长护险制度实行前后的结果变量对比:
ttable2 cost_clinic time_clinic cost_hos time_hos Age Gender married Edu_Group fainc chro gh pain cesd if Treat==1 , by(Post) format(%9.4f)--------------------------------------------------------------------------Variables G1(0) Mean1 G2(1) Mean2 MeanDiff--------------------------------------------------------------------------cost_clinic 49 152.0000 65 5.3846 146.6154*time_clinic 49 0.3061 65 0.0462 0.2600**cost_hos 49 2067.3469 65 1138.4615 928.8854time_hos 49 0.2041 65 0.1538 0.0502Age 49 61.0408 65 60.3846 0.6562Gender 49 0.5510 65 0.5385 0.0126married 49 0.8367 65 0.8769 -0.0402Edu_Group 49 2.9592 65 3.4462 -0.4870**fainc 49 4.81e+04 65 1.97e+04 2.83e+04***chro 49 1.1020 65 1.4000 -0.2980gh 49 2.0000 65 1.9231 0.0769pain 49 0.4286 65 0.1077 0.3209***cesd 49 4.6939 65 4.9692 -0.2754--------------------------------------------------------------------------
在政策之后,实验组的门诊花费(cost_clinic)和门诊次数(time_clinic)在政策前后存在显著的差异(0.05和0.1的显著性水平)。在政策施行后的2015年相比于2011,门诊花费降低了146.615元,门诊次数降低了0.26次。住院花费(cost_hos)和住院次数(time_hos)并未发生显著性的变化。
综合对比来看,控制组样本的门诊花费(cost_clinic)、门诊次数(time_clinic)、住院花费(time_clinic)、住院次数(time_hos)相比于政策施行前均有不同程度的增加,而实验组在政策施行后均有不同程度的下降。但我们仍然不能武断的做出长护险制度的施行是这一现象的原因,需要尽可能排除其它因素的影响才能得到相对可信的结果。
实验组政策前后对比结果输出到word文件名为table1a_descrip_control
logout, save(table1a_descrip_control) word replace:ttable2 cost_clinic time_clinic cost_hos time_hos Age Gender married Edu_Group fainc chro gh pain cesd if Treat==1 , by(Post) format(%9.4f)5.3基准回归分析
基准回归我们分享4种不同的命令(regress,reghdfe,diff,didregress)。regress为stata自带的线性回归命令,reghdfe和diff为需要安装的外部命令,didregress为stata17及其以上新增的用于did分析的官方命令。
5.3.1采用regress命令回归分析命令:'reg'和'regress'命令的缩写,其后的依次为结果变量(被解释变量),核心解释变量(因变量),控制变量。'vce(cluster city)'表示采用在城市层面的稳健标准误。'est store m*'表示将上一行的回归结果储存在内存中,命名为'm*'。
reg cost_clinic DID Post Treat Rural Age Gender married i.Edu_Group lnfainc chro gh pain cesd , vce(cluster city)est store m1 reg time_clinic DID Post Treat Rural Age Gender married i.Edu_Group lnfainc chro gh pain cesd , vce(cluster city)est store m2reg cost_hos DID Post Treat Rural Age Gender married i.Edu_Group lnfainc chro gh pain cesd , vce(cluster city)est store m3reg time_hos DID Post Treat Rural Age Gender married i.Edu_Group lnfainc chro gh pain cesd , vce(cluster city)est store m4回归结果集中汇报在结果窗口:esttab后输入需要集中汇报的回归结果名,nogap表示汇报结果不留空行,compress表示压缩列与列之间的空间。'ar2'和'r2'是指定报告R方和调整R方的选项,'scalar(N)'指定报告样本量,t指定报告T统计值而非标准误,'star(* 0.1 ** 0.05 *** 0.01)'指定显著性标注方式为:p值小于0.1标注“*”,p值小于0.05标注“**”,p值小于0.01标注“***”,'mtitle()'指定各模型的标题。
esttab m1 m2 m3 m4 ,replace nogap compress r2 ar2 scalar(N ) t star(* 0.1 ** 0.05 *** 0.01) mtitle('cost_clinic' 'time_clinic' 'cost_hos' 'time_hos')
结果如下:
-------------------------------------------------------------- (1) (2) (3) (4) cost_clinic time_clinic cost_hos time_hos --------------------------------------------------------------DID -199.6*** -0.239*** -1471.3*** -0.103*** (-25.05) (-16.30) (-30.30) (-15.76) Post 55.14*** 0.0118 493.7*** 0.0495*** (7.44) (0.91) (11.83) (9.19) Treat 84.17*** 0.00649 1774.0*** 0.148*** (12.18) (0.35) (45.34) (27.94) Rural -30.53*** 0.0232 -485.3*** -0.0297*** (-3.08) (1.04) (-7.94) (-4.42) Age 0.0715 -0.000176 20.27*** 0.00260*** (0.15) (-0.21) (6.15) (8.25) Gender 6.256 0.0481*** -128.6*** -0.0132*** (0.99) (3.81) (-3.06) (-2.66) married 7.620 0.0183 118.6 0.00458 (0.73) (1.00) (1.63) (0.53) 1.Edu_Gr~p 0 0 0 0 (.) (.) (.) (.) 2.Edu_Gr~p 12.52 0.0323 119.7** 0.0132* (1.29) (1.10) (2.02) (1.72) 3.Edu_Gr~p 25.24** 0.0148 129.8** 0.00525 (2.56) (0.62) (2.41) (0.74) 4.Edu_Gr~p 37.24*** 0.0116 258.9*** 0.0219*** (3.19) (0.48) (4.10) (2.74) 5.Edu_Gr~p 43.91*** 0.0191 212.3** 0.0174* (3.41) (0.70) (2.46) (1.72) lnfainc 4.152*** 0.00495** 15.68** 0.00146* (2.75) (2.00) (2.01) (1.69) chro 34.83*** 0.0795*** 236.4*** 0.0374*** (9.73) (11.36) (10.60) (13.98) gh 82.58*** 0.161*** 575.4*** 0.0748*** (11.45) (12.26) (11.87) (14.47) pain 29.26*** 0.132*** -5.509 0.00982 (3.53) (7.30) (-0.09) (1.48) cesd 2.495*** 0.00670*** 6.527 0.00130** (3.64) (4.91) (1.53) (2.47) _cons -214.4*** -0.313*** -2299.1*** -0.300*** (-4.93) (-4.20) (-7.60) (-9.65) --------------------------------------------------------------N 29391 29391 29391 29391 R-sq 0.037 0.064 0.047 0.067 adj. R-sq 0.037 0.063 0.046 0.067 --------------------------------------------------------------t statistics in parentheses* p<0.1, ** p<0.05, *** p<0.01上表报告了基准回归的结果,我们主要关注DID的估计系数。DID的估计系数在1%的水平通过显著性检验。长护险制度在青岛实行后,实验组的门诊费用平均降低了199.6元,去门诊的次数平均下降了0.239次,住院花费平均降低了1471.3元,住院次数平均降低了0.103次。
基准回归结果输出到word文件,table2_basireg.rtf: 若要将结果输出到word而不是在结果窗口回归,只需要在集中汇报命令中的逗号前加上'using'和数据路径,以及输出的文件名,如下所示。
esttab m1 m2 m3 m4 using 'table2_basireg.rtf',replace nogap compress r2 ar2 scalar(N ) t star(* 0.1 ** 0.05 *** 0.01) mtitle('月门诊费用' '月门诊次数' '年住院费用' '年住院次数')5.3.2采用外部命令reghdfe
'reghdfe'是用于高维固定效应回归的命令,在此处,与regress命令唯一的区别是需要加上'noabsorb'选项来说明回归不需要控制任何固定效应。
reghdfe cost_clinic DID Post Treat Rural Age Gender married i.Edu_Group lnfainc chro gh pain cesd , vce(cluster city) noabsorbest store m1 reghdfe time_clinic DID Post Treat Rural Age Gender married i.Edu_Group lnfainc chro gh pain cesd , vce(cluster city) noabsorbest store m2reghdfe cost_hos DID Post Treat Rural Age Gender married i.Edu_Group lnfainc chro gh pain cesd , vce(cluster city) noabsorbest store m3reghdfe time_hos DID Post Treat Rural Age Gender married i.Edu_Group lnfainc chro gh pain cesd , vce(cluster city) noabsorbest store m4回归结果集中汇报在结果窗口:
esttab m1 m2 m3 m4 ,replace nogap compress r2 ar2 scalar(N ) t star(* 0.1 ** 0.05 *** 0.01) mtitle('cost_clinic' 'time_clinic' 'cost_hos' 'time_hos')
结果如下:
-------------------------------------------------------------- (1) (2) (3) (4) cost_clinic time_clinic cost_hos time_hos --------------------------------------------------------------DID -199.6*** -0.239*** -1471.3*** -0.103*** (-25.05) (-16.30) (-30.30) (-15.76) Post 55.14*** 0.0118 493.7*** 0.0495*** (7.44) (0.91) (11.83) (9.19) Treat 84.17*** 0.00649 1774.0*** 0.148*** (12.18) (0.35) (45.34) (27.94) Rural -30.53*** 0.0232 -485.3*** -0.0297*** (-3.08) (1.04) (-7.94) (-4.42) Age 0.0715 -0.000176 20.27*** 0.00260*** (0.15) (-0.21) (6.15) (8.25) Gender 6.256 0.0481*** -128.6*** -0.0132*** (0.99) (3.81) (-3.06) (-2.66) married 7.620 0.0183 118.6 0.00458 (0.73) (1.00) (1.63) (0.53) 1.Edu_Gr~p 0 0 0 0 (.) (.) (.) (.) 2.Edu_Gr~p 12.52 0.0323 119.7** 0.0132* (1.29) (1.10) (2.02) (1.72) 3.Edu_Gr~p 25.24** 0.0148 129.8** 0.00525 (2.56) (0.62) (2.41) (0.74) 4.Edu_Gr~p 37.24*** 0.0116 258.9*** 0.0219*** (3.19) (0.48) (4.10) (2.74) 5.Edu_Gr~p 43.91*** 0.0191 212.3** 0.0174* (3.41) (0.70) (2.46) (1.72) lnfainc 4.152*** 0.00495** 15.68** 0.00146* (2.75) (2.00) (2.01) (1.69) chro 34.83*** 0.0795*** 236.4*** 0.0374*** (9.73) (11.36) (10.60) (13.98) gh 82.58*** 0.161*** 575.4*** 0.0748*** (11.45) (12.26) (11.87) (14.47) pain 29.26*** 0.132*** -5.509 0.00982 (3.53) (7.30) (-0.09) (1.48) cesd 2.495*** 0.00670*** 6.527 0.00130** (3.64) (4.91) (1.53) (2.47) _cons -214.4*** -0.313*** -2299.1*** -0.300*** (-4.93) (-4.20) (-7.60) (-9.65) --------------------------------------------------------------N 29391 29391 29391 29391 R-sq 0.037 0.064 0.047 0.067 adj. R-sq 0.037 0.063 0.046 0.067 --------------------------------------------------------------t statistics in parentheses* p<0.1, ** p<0.05, *** p<0.01基准回归结果输出到word文件,table2_basireg.rtf:
esttab m1 m2 m3 m4 using 'table2_basireg.rtf',replace nogap compress r2 ar2 scalar(N ) t star(* 0.1 ** 0.05 *** 0.01) mtitle('月门诊费用' '月门诊次数' '年住院费用' '年住院次数')5.3.3采用外部命令diff
'diff'是众多用于did分析的外部命令中的一个,由于diff在考虑控制变量时不能输入factor variable(上文中的i.Edu_Group),因此需要将Edu_Group转化为dummy variables,因此需要先运行'tab Edu_Group , gen(Edu)'。
'diff'的使用方法是将结果变量放在命令之后,在选项部分指定实验组和控制组的识别变量和政策实行前后的识别变量以及控制变量。't()'指定分组变量,'p()'指定政策时间前后的区分变量,'cv()'指定控制变量,'cluster()'表示使用聚类标准误,若不加该选项就是不使用聚类标准误,report指需要报告完整的回归结果。
先以对cost_clinic(门诊花费)的分析为例:
tab Edu_Group , gen(Edu) //生成最高学历的虚拟变量diff cost_clinic, t(Treat) p(Post) cov(Rural Age Gender married Edu2 Edu3 Edu4 Edu5 lnfainc chro gh pain cesd) cluster(city) report在不加'report'选项下,'diff'命令分别报告了在考虑控制变量的情况下,在政策之前(Before)与之后(after)控制组和实验组的结果变量均值及其之间的差异和显著性检验,最后一行报告了双重差分的结果,即前文中的DID变量的估计参数。借助这个表,我们可以更好的理解平行趋势假设的重要性,最后一行(Diff-on-Diff)的估计系数正好是政策实行之前控制组与实验组的差异减去政策实行之前的差异,其差值能表示政策效应的一个重要假设是在政策没有实行的情况下,政策后实验组和控制组在结果变量上的差异应该与政策实行之前不具有显著的不同,即就算有不同也是由随机性产生的,如果统计检验说明该“不同”具有统计上的意义,就可以合理推断该'不同'是由政策实行导致的。
-------------------------------------------------------- Outcome var. | cost_~c | S. Err. | |t| | P>|t|----------------+---------+---------+---------+---------Before | | | | Control | -214.368| | | Treated | -130.195| | | Diff (T-C) | 84.173 | 6.913 | 12.18 | 0.000***After | | | | Control | -159.225| | | Treated | -274.620| | | Diff (T-C) | -115.395| 6.212 | 18.58 | 0.000*** | | | | Diff-in-Diff | -199.568| 7.967 | 25.05 | 0.000***--------------------------------------------------------
同样,采用diff也可以将基准回归结果汇总汇报:
diff cost_clinic, t(Treat) p(Post) cov(Rural Age Gender married Edu2 Edu3 Edu4 Edu5 lnfainc chro gh pain cesd) cluster(city) reportest store m1diff time_clinic, t(Treat) p(Post) cov(Rural Age Gender married Edu2 Edu3 Edu4 Edu5 lnfainc chro gh pain cesd) cluster(city) est store m2diff cost_hos, t(Treat) p(Post) cov(Rural Age Gender married Edu2 Edu3 Edu4 Edu5 lnfainc chro gh pain cesd) cluster(city) est store m3diff time_hos, t(Treat) p(Post) cov(Rural Age Gender married Edu2 Edu3 Edu4 Edu5 lnfainc chro gh pain cesd) cluster(city) est store m4回归结果集中汇报在结果窗口:
esttab m1 m2 m3 m4 ,replace nogap compress r2 ar2 scalar(N ) t star(* 0.1 ** 0.05 *** 0.01) mtitle('cost_clinic' 'time_clinic' 'cost_hos' 'time_hos')
结果如下:'_diff'变量就是前文中的DID变量,回归结果也与regress命令和reghdfe命令一致。
-------------------------------------------------------------- (1) (2) (3) (4) cost_cl~c time_cl~c cost_hos time_hos --------------------------------------------------------------Post 55.14*** 0.0118 493.7*** 0.0495*** (7.44) (0.91) (11.83) (9.19) Treat 84.17*** 0.00649 1774.0*** 0.148*** (12.18) (0.35) (45.34) (27.94) _diff -199.6*** -0.239*** -1471.3*** -0.103*** (-25.05) (-16.30) (-30.30) (-15.76) Rural -30.53*** 0.0232 -485.3*** -0.0297*** (-3.08) (1.04) (-7.94) (-4.42) Age 0.0715 -0.000176 20.27*** 0.00260*** (0.15) (-0.21) (6.15) (8.25) Gender 6.256 0.0481*** -128.6*** -0.0132*** (0.99) (3.81) (-3.06) (-2.66) married 7.620 0.0183 118.6 0.00458 (0.73) (1.00) (1.63) (0.53) Edu2 12.52 0.0323 119.7** 0.0132* (1.29) (1.10) (2.02) (1.72) Edu3 25.24** 0.0148 129.8** 0.00525 (2.56) (0.62) (2.41) (0.74) Edu4 37.24*** 0.0116 258.9*** 0.0219*** (3.19) (0.48) (4.10) (2.74) Edu5 43.91*** 0.0191 212.3** 0.0174* (3.41) (0.70) (2.46) (1.72) lnfainc 4.152*** 0.00495** 15.68** 0.00146* (2.75) (2.00) (2.01) (1.69) chro 34.83*** 0.0795*** 236.4*** 0.0374*** (9.73) (11.36) (10.60) (13.98) gh 82.58*** 0.161*** 575.4*** 0.0748*** (11.45) (12.26) (11.87) (14.47) pain 29.26*** 0.132*** -5.509 0.00982 (3.53) (7.30) (-0.09) (1.48) cesd 2.495*** 0.00670*** 6.527 0.00130** (3.64) (4.91) (1.53) (2.47) _cons -214.4*** -0.313*** -2299.1*** -0.300*** (-4.93) (-4.20) (-7.60) (-9.65) --------------------------------------------------------------N 29391 29391 29391 29391 R-sq 0.037 0.064 0.047 0.067 adj. R-sq 0.037 0.063 0.046 0.067 --------------------------------------------------------------t statistics in parentheses* p<0.1, ** p<0.05, *** p<0.01导出到word的命令与前面一致。
5.3.4采用didregress(仅stata17及以上可用)'didregress'是stata17及其以上版本才能使用的官方命令,在应用到两期标准DID模型时其基本语法结构为:didregress (ovar omvarlist) (tvar) , group(groupvar) time(timevar) options
'ovar'为结果变量,'omvarlist'为一组协变量/控制变量。'tvar'是用于表示哪些观测受到政策的影响,需要注意的是这里识别的是观测,例如某属于青岛的个体A(长护险制度在青岛2012施行,属于实验组),在数据中会产生2011年和2015年两个观测,但只有在长护险政策实行之后的2015年观测才会受到政策的影响。因此对于这个个体A,其在2011年的观测对应的'tvar'取0,对应2015年观测的'tvar'取值为0,在我们的案例中,'tvar'就是DID。
'groupvar'是用于识别个体属于实验组还是控制组的dummy variable,上文中的个体A,无论有关于其在2011年的观测还是在2015年的观测,'groupvar'都应赋值为1,案例中的'Treat'就是'groupvar'。
'timevar'可看作是用于识别政策发生时间的dummy varibale,对应我们设置的'Post'。'option'代表其他一系列可选条件的设置,'vce(cluster city)'的含义与前文一致,aequations在需要报告协变量/控制变量的估计结果时使用。需要注意得是,'didregress'同样不支持factor variable的使用,同时不会报告'Post'的估计系数。
didregress (cost_clinic Rural Age Gender married Edu2 Edu3 Edu4 Edu5 lnfainc chro gh pain cesd) (DID), group(Treat) time(Post) vce(cluster city) aequationsest store m1didregress (time_clinic Rural Age Gender married Edu2 Edu3 Edu4 Edu5 lnfainc chro gh pain cesd) (DID), group(Treat) time(Post) vce(cluster city) aequationsest store m2didregress (cost_hos Rural Age Gender married Edu2 Edu3 Edu4 Edu5 lnfainc chro gh pain cesd) (DID), group(Treat) time(Post) vce(cluster city) aequationsest store m3didregress (time_hos Rural Age Gender married Edu2 Edu3 Edu4 Edu5 lnfainc chro gh pain cesd) (DID), group(Treat) time(Post) vce(cluster city) aequationsest store m4
回归结果集中汇报在结果窗口:
esttab m1 m2 m3 m4 ,replace nogap compress r2 ar2 scalar(N ) t star(* 0.1 ** 0.05 *** 0.01) mtitle('cost_clinic' 'time_clinic' 'cost_hos' 'time_hos')结果如下:
-------------------------------------------------------------- (1) (2) (3) (4) cost_cl~c time_cl~c cost_hos time_hos --------------------------------------------------------------ATET r1vs0.DID -199.6*** -0.239*** -1471.3*** -0.103*** (-25.05) (-16.30) (-30.30) (-15.76) --------------------------------------------------------------Controls Rural -30.53*** 0.0232 -485.3*** -0.0297*** (-3.08) (1.04) (-7.94) (-4.42) Age 0.0715 -0.000176 20.27*** 0.00260*** (0.15) (-0.21) (6.15) (8.25) Gender 6.256 0.0481*** -128.6*** -0.0132*** (0.99) (3.81) (-3.06) (-2.66) married 7.620 0.0183 118.6 0.00458 (0.73) (1.00) (1.63) (0.53) Edu2 12.52 0.0323 119.7** 0.0132* (1.29) (1.10) (2.02) (1.72) Edu3 25.24** 0.0148 129.8** 0.00525 (2.56) (0.62) (2.41) (0.74) Edu4 37.24*** 0.0116 258.9*** 0.0219*** (3.19) (0.48) (4.10) (2.74) Edu5 43.91*** 0.0191 212.3** 0.0174* (3.41) (0.70) (2.46) (1.72) lnfainc 4.152*** 0.00495** 15.68** 0.00146* (2.75) (2.00) (2.01) (1.69) chro 34.83*** 0.0795*** 236.4*** 0.0374*** (9.73) (11.36) (10.60) (13.98) gh 82.58*** 0.161*** 575.4*** 0.0748*** (11.45) (12.26) (11.87) (14.47) pain 29.26*** 0.132*** -5.509 0.00982 (3.53) (7.30) (-0.09) (1.48) cesd 2.495*** 0.00670*** 6.527 0.00130** (3.64) (4.91) (1.53) (2.47) 0.Post 0 0 0 0 (.) (.) (.) (.) 1.Post 55.14*** 0.0118 493.7*** 0.0495*** (7.44) (0.91) (11.83) (9.19) _cons -214.0*** -0.313*** -2292.3*** -0.299*** (-4.93) (-4.20) (-7.58) (-9.63) --------------------------------------------------------------N 29391 29391 29391 29391 R-sq adj. R-sq --------------------------------------------------------------5.4 进一步分析
基准回归分析是否仍然存在瑕疵,这是我们需要考虑的问题。通过总体数据的描述性统计分析,我们可以清楚看到,4个结果变量的最小值和中位数均为0,峰度过高,偏度远离0,说明4个结果变量的取值大部分为最低值0,同时0到高值之间不存在明显的过渡区间。这就引出一个关键问题,我们所考虑的协变量与因变量和这4个结果变量是否可能不是线性关系,或者说线性关系不能很准确的解释协变量与因变量和这4个结果变量之间的关系,可能低谷长护险的政策效应。
重新回到4个结果变量的描述性分析:
tabstat cost_clinic time_clinic cost_hos time_hos,s(n mean sd min p25 p50 p75 max k sk) c(v)查看结果:
Stats | cost_c~c time_c~c cost_hos time_hos---------+---------------------------------------- N | 29391 29391 29391 29391 Mean | 120.0818 .3545303 725.6395 .1069715 SD | 518.2586 .9212584 3311.203 .3766619 Min | 0 0 0 0 p25 | 0 0 0 0 p50 | 0 0 0 0 p75 | 0 0 0 0 Max | 4000 5 25000 2Kurtosis | 41.89921 14.01949 37.96861 16.70562Skewness | 6.052325 3.235013 5.737651 3.728614--------------------------------------------------
我们也可以通过画出核密度图来直观说明。
'kdensity'是用于画核密度图的命令,ylabel用于指定坐标轴的标签,legend用于指定图例,graphregion用于指定区域颜色。'graph save'将图保存为gph格式,'graph combine'用于将gph格式的图合并为一张图,'graph export'用于将图导出为其他格式。
kdensity cost_clinic ,ylabel(#4, format(%9.4f)) legend(off) graphregion(fcolor(white) ifcolor(white))graph save 'cost_clinic.gph' ,replacekdensity time_clinic ,ylabel(, format(%9.1f)) legend(off) graphregion(fcolor(white) ifcolor(white))graph save 'time_clinic.gph' ,replacekdensity cost_hos ,ylabel(#3, format(%9.4f)) legend(off) graphregion(fcolor(white) ifcolor(white))graph save 'cost_hos.gph' ,replacekdensity time_hos ,ylabel(, format(%9.0f)) legend(off) graphregion(fcolor(white) ifcolor(white))graph save 'time_hos.gph' ,replacegraph combine 'cost_clinic.gph' 'time_clinic.gph' 'cost_hos.gph' 'time_hos.gph' ,row(2)graph export 'figure1_kernal.png' ,width(1920) height(1500) replace图片
Fig 1: 结果变量核密度图5.4.1 进行tobit回归若我们将结果变量的这种数据分布特征简单的看作一种截尾分布。即简单地认为只有身体状态的难受程度达到一定阈值,才会去门诊,结果变量存在存在'负值',但负值由于客观情况都取值为0了。或者说,在门诊之下,以及门诊和住院之间,若存在其它更加具有连续性的过渡医疗服务,那么,我们的结果变量将接近正态分布或者T分布。(实际上,这样的假设不一定具有合理性和现实性,因为对现实做出了太大的假想。以后有机会我们可以专门出专题讨论这样的问题,在此处作为学习的案例,可以姑且一试。)
因此,我们现有的数据的分布仅仅是正态分布或者某种对称分布的右半部分,因此,可以采用tobit模型,对于tobit,在此处可以简单理解为采用部分线性的分段方程进行拟合。以下为tobit回归的代码,'tobit'是回归的指令,'ll(0)'是说明数据在下限为0处产生了截尾。
tobit cost_clinic DID Post Treat Age Gender married i.Edu_Group lnfainc chro gh pain cesd , vce(cluster city) ll(0)est store m1 tobit time_clinic DID Post Treat Age Gender married i.Edu_Group lnfainc chro gh pain cesd , vce(cluster city) ll(0)est store m2tobit cost_hos DID Post Treat Age Gender married i.Edu_Group lnfainc chro gh pain cesd , vce(cluster city) ll(0)est store m3tobit time_hos DID Post Treat Age Gender married i.Edu_Group lnfainc chro gh pain cesd , vce(cluster city) ll(0)est store m4esttab m1 m2 m3 m4 ,replace nogap compress scalar(N r2_p) t star(* 0.1 ** 0.05 *** 0.01) mtitle('cost_clinic' 'time_clinic' 'cost_hos' 'time_hos')
得到tobit回归结果:我们可以看到估计结果显示,在长护险政策实行后,实验组的门诊费用平均降低了1844.4元,去门诊的次数平均下降了3.157次,住院花费平均降低了8437.5元,住院次数平均降低了0.848次,tobit估计出的长护险效应(平均边际效应)已经很接近各自的最大值,这在很大程度上违背了常识,可以怀疑tobit估计结果夸大了长护险的政策效应。
-------------------------------------------------------------- (1) (2) (3) (4) cost_cl~c time_cl~c cost_hos time_hos --------------------------------------------------------------main DID -1844.0*** -3.157*** -8437.5*** -0.848*** (-27.59) (-37.83) (-13.81) (-10.99) Post 138.1*** 0.0498 4056.8*** 0.460*** (3.99) (0.73) (8.25) (7.37) Treat 314.4*** 0.248*** 11949.1*** 1.313*** (6.88) (2.62) (20.36) (17.96) Age -1.295 -0.00248 247.3*** 0.0304*** (-0.61) (-0.60) (7.76) (8.57) Gender 99.75*** 0.252*** -897.3* -0.111* (3.18) (3.98) (-1.91) (-1.89) married 39.57 0.0716 475.3 0.0198 (0.92) (0.84) (0.75) (0.25) 1.Edu_Gr~p 0 0 0 0 (.) (.) (.) (.) 2.Edu_Gr~p 80.33 0.146 1466.4** 0.166* (1.49) (1.15) (2.05) (1.82) 3.Edu_Gr~p 110.7** 0.116 1072.7* 0.0814 (2.30) (1.05) (1.71) (1.00) 4.Edu_Gr~p 142.5** 0.105 2876.7*** 0.293*** (2.52) (0.89) (4.07) (3.28) 5.Edu_Gr~p 190.4*** 0.141 3366.5*** 0.322*** (2.78) (0.97) (3.96) (3.03) lnfainc 23.28*** 0.0320*** 228.2** 0.0240** (3.59) (2.66) (2.36) (2.05) chro 181.9*** 0.365*** 2440.6*** 0.322*** (14.06) (14.34) (15.57) (17.02) gh 476.6*** 0.894*** 6721.9*** 0.838*** (15.34) (15.48) (13.11) (15.78) pain 233.8*** 0.564*** 612.9 0.111* (6.53) (7.46) (1.14) (1.66) cesd 13.06*** 0.0277*** 62.72 0.00913* (4.70) (4.77) (1.64) (1.85) _cons -3413.0*** -6.176*** -65473.2*** -8.054*** (-14.89) (-17.47) (-17.67) (-22.85) --------------------------------------------------------------/ var..cos~) 2329803.9*** (15.65) var..tim~) 9.453*** (36.75) var..cos~) 307714041.5*** (17.28) var..tim~) 4.959*** (42.74) --------------------------------------------------------------N 29391 29391 29391 29391 r2_p 0.0173 0.0438 0.0252 0.0759 --------------------------------------------------------------tobit回归结果输出到word文件,table3a_tobit.rtf:
esttab m1 m2 m3 m4 using '$path/table/table3a_tobit.rtf',replace nogap compress scalar(N r2_p) t star(* 0.1 ** 0.05 *** 0.01) mtitle('月门诊费用' '月门诊次数' '年住院费用' '年住院次数')5.4.2 利用负二项回归进行估计
从结果变量的描述性统计分析可知,结果变量存在过渡分散的特征,即方差明显大于期望,尝试采用零膨胀负二项回归。(负二项回归一般用于因变量为计数型数据的模型,在我们的案例中,花费并非是计数型数据,在根据其分布特征与计数型数据具有相似性,我们将其当作计数型数据进行处理) stata的实现代码如下:'nbreg'是负二项回归的命令,'margins , dydx(*) post'用于估计平均边际效应。
nbreg cost_clinic DID Post Treat Age Gender married i.Edu_Group lnfainc chro gh pain cesd , vce(cluster city) margins , dydx(*) postest store m1 nbreg time_clinic DID Post Treat Age Gender married i.Edu_Group lnfainc chro gh pain cesd , vce(cluster city) margins , dydx(*) postest store m2nbreg cost_hos DID Post Treat Age Gender married i.Edu_Group lnfainc chro gh pain cesd , vce(cluster city) margins , dydx(*) postest store m3nbreg time_hos DID Post Treat Age Gender married i.Edu_Group lnfainc chro gh pain cesd , vce(cluster city) margins , dydx(*) postest store m4esttab m1 m2 m3 m4 ,replace nogap compress scalar(N r2_p) t star(* 0.1 ** 0.05 *** 0.01) mtitle('cost_clinic' 'time_clinic' 'cost_hos' 'time_hos')我们得到如下结果:
-------------------------------------------------------------- (1) (2) (3) (4) cost_cl~c time_cl~c cost_hos time_hos --------------------------------------------------------------DID -782.9*** -0.641*** -1844.4*** -0.0961*** (-19.55) (-23.59) (-11.79) (-12.09) Post 54.40*** 0.0158 491.3*** 0.0453*** (5.64) (1.12) (7.09) (7.46) Treat 239.8*** -0.0261 1529.1*** 0.122*** (16.13) (-1.31) (14.72) (21.38) Age 0.473 0.000691 23.07*** 0.00299*** (0.91) (0.79) (5.98) (9.29) Gender 6.967 0.0563*** -138.1** -0.0105** (0.80) (4.20) (-2.40) (-2.03) married -7.281 0.0127 37.27 0.00383 (-0.51) (0.71) (0.42) (0.55) 1.Edu_Gr~p 0 0 0 0 (.) (.) (.) (.) 2.Edu_Gr~p 27.14** 0.0469 136.7 0.0150** (2.11) (1.61) (1.36) (1.99) 3.Edu_Gr~p 30.26*** 0.0228 72.88 0.00603 (2.84) (1.00) (0.99) (0.91) 4.Edu_Gr~p 52.53*** 0.00729 286.5*** 0.0278*** (3.94) (0.31) (2.85) (3.41) 5.Edu_Gr~p 72.65*** 0.0120 337.7*** 0.0319*** (3.70) (0.39) (2.93) (3.01) lnfainc 5.826*** 0.00591** 19.74 0.00221** (2.86) (2.29) (1.62) (2.13) chro 34.99*** 0.0703*** 218.1*** 0.0283*** (9.89) (10.93) (8.28) (13.93) gh 89.03*** 0.186*** 600.6*** 0.0833*** (10.29) (12.10) (8.86) (14.29) pain 33.59*** 0.123*** 91.28 0.0103* (4.21) (7.48) (1.16) (1.73) cesd 2.101*** 0.00542*** 11.02** 0.000891** (2.92) (4.61) (2.01) (1.97) --------------------------------------------------------------N 29391 29391 29391 29391 r2_p --------------------------------------------------------------t statistics in parentheses* p<0.1, ** p<0.05, *** p<0.01
根据负二项回归的结果,在长护险政策实行后,实验组的门诊费用平均降低了-782.9元,去门诊的次数平均下降了0.641次,住院花费平均降低了1844.4元,住院次数平均降低了-0.0961次,估计结果在线性回归和tobit模型之间。
5.4.3 将结果变量进行对数化处理在这里只是提供一种思路,针对本次的案例分析,取对数其实并不能解决结果变量的截尾分布问题。因为4个结果变量均在最低值0截尾,取对数也会导致变化后的数据在最低值0截尾。首先对结果变量取对数,代码如下:
foreach var in cost_clinic time_clinic cost_hos time_hos{ gen ln`var'=ln(`var'+1)}然后进行回归:
reg lncost_clinic DID Post Treat Age Gender married i.Edu_Group lnfainc chro gh pain cesd , vce(cluster city)est store m1 reg lntime_clinic DID Post Treat Age Gender married i.Edu_Group lnfainc chro gh pain cesd , vce(cluster city)est store m2reg lncost_hos DID Post Treat Age Gender married i.Edu_Group lnfainc chro gh pain cesd , vce(cluster city)est store m3reg lntime_hos DID Post Treat Age Gender married i.Edu_Group lnfainc chro gh pain cesd , vce(cluster city)est store m4esttab m1 m2 m3 m4 ,replace nogap compress r2 ar2 scalar(N ) t star(* 0.1 ** 0.05 *** 0.01) mtitle('月门诊费用' '月门诊次数' '年住院费用' '年住院次数')
回归结果如下:
-------------------------------------------------------------- (1) (2) (3) (4) lncost_~c lntime_~c lncost_~s lntime_~s --------------------------------------------------------------DID -0.900*** -0.130*** -0.455*** -0.0527*** (-27.01) (-19.00) (-11.63) (-13.37) Post 0.135*** 0.00635 0.296*** 0.0281*** (4.38) (1.03) (8.76) (8.58) Treat 0.190*** 0.0103 0.901*** 0.0841*** (4.84) (1.22) (26.82) (26.13) Age -0.00292 -0.000353 0.0169*** 0.00169*** (-1.47) (-0.92) (7.74) (8.41) Gender 0.119*** 0.0220*** -0.0647* -0.00665** (4.22) (3.79) (-1.95) (-2.16) married 0.0456 0.00743 0.0287 0.00196 (1.10) (0.88) (0.55) (0.38) 1.Edu_Gr~p 0 0 0 0 (.) (.) (.) (.) 2.Edu_Gr~p 0.0465 0.0131 0.0954* 0.00909* (0.85) (1.03) (1.86) (1.89) 3.Edu_Gr~p 0.0861* 0.00839 0.0695 0.00518 (1.80) (0.78) (1.57) (1.20) 4.Edu_Gr~p 0.120** 0.00645 0.202*** 0.0177*** (2.23) (0.57) (4.04) (3.68) 5.Edu_Gr~p 0.164** 0.00822 0.230*** 0.0199*** (2.57) (0.62) (3.86) (3.42) lnfainc 0.0197*** 0.00252** 0.0146** 0.00124** (3.42) (2.32) (2.42) (2.27) chro 0.212*** 0.0384*** 0.231*** 0.0232*** (14.29) (12.37) (14.13) (14.41) gh 0.428*** 0.0777*** 0.460*** 0.0449*** (14.42) (12.99) (14.11) (14.38) pain 0.287*** 0.0616*** 0.0355 0.00526 (7.07) (7.42) (0.80) (1.26) cesd 0.0152*** 0.00319*** 0.00549* 0.000664** (5.12) (5.23) (1.80) (2.13) _cons -0.716*** -0.112*** -2.050*** -0.203*** (-4.21) (-3.54) (-10.05) (-10.72) --------------------------------------------------------------N 29391 29391 29391 29391 R-sq 0.071 0.070 0.060 0.065 adj. R-sq 0.071 0.070 0.059 0.065 --------------------------------------------------------------t statistics in parentheses* p<0.1, ** p<0.05, *** p<0.01参考文献[1] Villa, J. M. . (2016). Diff: simplifying the estimation of difference-in-differences treatment effects. Stata Journal, 16(1), págs. 52-71.
[2] Greene, W. H. . (2018). Econometric analysis.Pearson Education India.
[3]马超,俞沁雯,宋泽 & 陈昊.(2019).长期护理保险、医疗费用控制与价值医疗. 中国工业经济(12)香港股票 杠杆,42-59.
本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报。