stata进行空间计量分析

第一步,打开是stata14,安装xsmle(本文使用的是面板数据);

ssc install xsmle

第二步,打开要分析的文件;

首先,单击file—import—选择导入的文件形式(本文导入的是.xls)

在这里插入图片描述

然后,点击Browse,找到所需要的文件,点击OK;

在这里插入图片描述
在这里插入图片描述

第三步,将变量取对数;

gen lnGDP = log(GDP)
gen lnpersonel = log(personel)
gen lnincome = log(income)
gen lnRdfare = log(Rdfare)
gen lnexport = log(export)
gen ln(location) = log(location)
gen lnscienceExpense = log(scienceExpense)

第四步,导入权重矩阵;

将权重矩阵.xls转换为.dta格式,并保存(本文命名为weight.dta)

在这里插入图片描述

第五步,使用xtset设置region和year(格式为xtset region year);

xtset state A

第六步,将权重矩阵weight.dta标准化;

spatwmat using weight.dta,n(W1) standardize

第七步,使用聚类稳健的标准误估计随机效应的SDM模型;

xsmle lnGDP lnpersonel lnincome lnexport lnRdfare lnlocation lnscienceExpense,wmat(W1) model(sdm)  robust nolog
//个体效应
xsmle lnGDP lnpersonel lnincome lnexport lnRdfare lnlocation lnscienceExpense,wmat(W1) model(sdm)  robust nolog type(ind)
//时间效应
xsmle lnGDP lnpersonel lnincome lnexport lnRdfare lnlocation lnscienceExpense,wmat(W1) model(sdm)  robust nolog type(time)
//双效应
xsmle lnGDP lnpersonel lnincome lnexport lnRdfare lnlocation lnscienceExpense,wmat(W1) model(sdm)  robust nolog type(both)

如果使用SAR模型,则输入以下形式:

xsmle lnGDP lnpersonel lnincome lnexport lnRdfare lnlocation lnscienceExpense,wmat(W1) model(sar)  robust nolog

如果使用SEM模型,则输入以下形式:

 xsmle lnGDP lnpersonel lnincome lnexport lnRdfare lnlocation lnscienceExpense,emat(W1) model(sem) robust nolog

第八步,进行固定效应的估计;

固定效应也分为时间固定、个体固定和双向固定,本文仅列举固定效应中的空间杜宾模型。若要加上时间固定、个体固定、双固定,在后面加上type(time),type(ind),type(both)即可。

xsmle lnGDP lnpersonel lnincome lnexport lnRdfare lnlocation lnscienceExpense,wmat(W1)  model(sdm) robust nolog fe

第九步,进行固定效应AIC和BIC检验

estat ic

AIC和BIC越小越好。

最后,进行豪斯曼检验,判断使用随机效应模型还是固定效应模型;

qui xsmle lnGDP lnpersonel lnincome lnexport lnRdfare lnlocation lnscienceExpense,wmat(W1)  model(sdm)   nolog re
est sto re
qui xsmle lnGDP lnpersonel lnincome lnexport lnRdfare lnlocation lnscienceExpense,wmat(W1)  model(sdm)   nolog fe
est sto fe
// 豪斯曼检验
hausman fe re

如果豪斯曼统计量的p值大于0.1,则接受随机效应的原假设;否则,接受备择假设,选择固定效应

  • 55
    点赞
  • 445
    收藏
    觉得还不错? 一键收藏
  • 30
    评论
评论 30
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值