新浪博客

stata:SAR\SEM模型步骤与命令

2017-02-20 14:22阅读:
. import excel 'C:\Users\张燕\Desktop\working paper\“荷兰病”空间效应\荷兰病\论文写作\stata
> 用表20170218.xlsx', sheet('Sheet1') firstrow %表格当中不出现地区名,用数字表示,年份也用数字表示,表格排列方式:area year Y x1 x2···,30个地区21年数据排成30*21的矩阵(每个地区21年数据,依次排成30个地区)
. save 'C:\Users\张燕\Desktop\DD.dta' %原始数据储存成stata格式
file C:\Users\张燕\Desktop\DD.dta saved
. use 'C:\Users\张燕\Desktop\W.dta', clear %输入0-1权重矩阵
. spmat dta W s*, normalize(row) %权重矩阵行标准化
use 'C:\Users\张燕\Desktop\DD.dta', clear %重新载入stata格式的变量数据
xtset area year %定义面板数据
xsmle LM RA RD1 RD2 LPOP LM1, wmat(W) model(sar) fe type(both) nsim(500) %空间模型回归
xsmle LM RA RD1 RD2 LPOP LM1, emat(W) model(sem) fe type(both)
xsmle CM RA RD1 RD2 Y CM1, wmat(W) model(sar) fe type(both) nsim(500)
xsmle CM RA RD1 RD2 Y CM1, emat(W) model(sem) fe type(both) nsim(500)

. xsmle I RA RD1 RD2 LFR I1, wmat(W) model(sar) fe type(both)
nsim(500)
. xsmle I RA RD1 RD2 LFR I1, emat(W) model(sem) fe type(both) nsim(500)
xsmle I RA RD1 RD2 LFR I1, wmat(W) model(sdm) fe type(both) nsim(500) nolog
%sar模型hausman检验%
xsmle LM RA RD1 RD2 LPOP LM1, wmat(W) model(sar) fe type(both) nsim(500)%sar模型固定效应
estimates store sar_fe%存取估计结果
xsmle LM RA RD1 RD2 LPOP LM1, wmat(W) model(sar) re type(both) nsim(500)%sar模型随机效应
estimates store sar_re
hausman sar_fe sar_re%hausman检验,P值小于0.05,表明模型选择固定效应

我的更多文章

下载客户端阅读体验更佳

APP专享