帮着导师作了一个空间面板计量模型的课题研究,之前在帖子里收集到很多很好的方法和资料,现在也来小小的回报一下~~
因为数据及内容要保密,就贴上本人的stata命令
另推荐J.Paul Elhorst中英文《空间计量经济学:从截面数据到空间面板》、汉密尔顿《应用stata做统计分析》PDF~
因为上述资源论坛已有,无法上传,但是本人觉得这两本书比较实用,附上网盘地址:
链接:https://pan.baidu.com/s/1htiI0Ws 密码:s5g4
(ps:本人空间计量初学者一枚,不喜勿喷)
*--------------------------------------------------------------
*do文件:
*因为数据缺漏较多,先填补缺漏值(详见连玉君老师初级视频教程A2_data_05_ommit_p)
use variable.dta,clear
mi set wide
mi register imputed secondind thirdind wifi electric
mi impute regress secondind ma trade pergdp tel chinnito edu,add(80) rseed(13579)
mi impute regress thirdind ma trade pergdp tel chinnito edu,add(80) rseed(13579)
mi impute regress wifi ma trade pergdp tel chinnito edu,add(80) rseed(13579)
mi impute regress electric ma trade pergdp tel chinnito edu,add(80) rseed(13579)
mi estimate:regress ma secondind thirdind trade pergdp tel wifi electric chinnito edu
est store ols_m
egen secondind_m = rowmean(_*_secondind)
egen thirdind_m = rowmean(_*_thirdind)
egen wifi_m = rowmean(_*_wifi)
egen electric_m = rowmean(_*_electric)
reg ma secondind_m thirdind_m trade pergdp tel wifi_m electric_m chinnito edu
est store ols_m
esttab ols ols_m
*空间计量模型stata命令
*生成W2.spmat格式的空间权重矩阵(详见论坛https://bbs.pinggu.org/thread-4590876-1-1.html,超级棒)
spmat dta W1 var1-var11
spmat save W1 using "D:\W2.spmat"
*导入空间矩阵
spatwmat using w.dta,name(W)
matrix list W
*计算莫兰指数(仅适用截面数据)
use crosssection.dta,clear
spatgsa ma,weights(W) moran geary
logout,save(moran_gsa) word:spatlsa ma,w(W) moran
*空间计量模型
use variable_m.dta,clear
xtset states year
*SAR
xsmle ma secondind_m thirdind_m trade pergdp tel wifi_m electric_m chinnito edu, fe wmat(W)
est store SAR_fe
xsmle ma secondind_m thirdind_m trade pergdp tel wifi_m electric_m chinnito edu, re wmat(W)
est store SAR_re
hausman fe re
*SDM
xsmle ma secondind_m thirdind_m trade pergdp tel wifi_m electric_m chinnito edu, fe model(sdm) wmat(W)
est store SDM_fe
xsmle ma secondind_m thirdind_m trade pergdp tel wifi_m electric_m chinnito edu, re model(sdm) wmat(W)
est store SDM_re
hausman fe re
*SAC
xsmle ma secondind_m thirdind_m trade pergdp tel wifi_m electric_m chinnito edu, fe model(sac) wmat(W) emat(W)
est store SAC_fe
*SEM model
xsmle ma secondind_m thirdind_m trade pergdp tel wifi_m electric_m chinnito edu, fe model(sem) emat(W)
est store SEM_fe
xsmle ma secondind_m thirdind_m trade pergdp tel wifi_m electric_m chinnito edu, re model(sem) emat(W)
est store SEM_re
hausman fe re
esttab SAR SDM SAC SEM GSPRE using SARSDMSACSEMGSPRE.csv, ///
compress nogap star(* 0.1 ** 0.05 *** 0.01)
*GSPRE model
xsmle ma secondind_m thirdind_m trade pergdp tel wifi_m electric_m chinnito edu, re model(gspre) error(1)wmat(W) emat(W)
est store GSPRE
*对比上述模型
esttab SDM_fe ols using SDMOLS.csv, compress nogap star(* 0.1 ** 0.05 *** 0.01)