|
第一步,打开是stata14,安装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)
然后,在stata中打开(a1-a31是所有的变量的变量名,注意W0是新的名字,可以换成任何的名字)
接着,储存W0(引号里是存储位置,新的spmat的名字叫W3,可以换成任何名字)
- spmat save W0 using "F:\Desktop\空间计量的论文\W3.spmat"
复制代码
最后,打开刚生成的spmat文件(W33也是新的名字,打开的时候命名)
- spmat use W33 using "F:\Desktop\空间计量的论文\W3.spmat"
复制代码
第五步,使用xtset设置region和year(格式为xtset region year);
第六步,将权重矩阵W33标准化;
- 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检验
最后,进行豪斯曼检验,判断使用随机效应模型还是固定效应模型;
- qui xsmle lnGDP lnpersonel lnincome lnexport lnRdfare lnlocation lnscienceExpense,wmat(W1) model(sdm) nolog
- est sto re
- qui xsmle lnGDP lnpersonel lnincome lnexport lnRdfare lnlocation lnscienceExpense,wmat(W1) model(sdm) nolog fe
- est sto fe
- // 豪斯曼检验
- hausman fe re
复制代码
如果豪斯曼统计量小于零,则接受随机效应的原假设 |
|