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,则接受随机效应的原假设;否则,接受备择假设,选择固定效应。