第一步,打開是stata14,安裝xsmle(本文使用的是面板數(shù)據(jù))
ssc install xsmle
第二步,打開要分析的文件
cd??D:\experiments(確定文件位置)
use "data.dta"(使用面板數(shù)據(jù)文件)
ssc install sppack(下載包含?spmat的包,spmat允許創(chuàng)建基于鄰近和基于距離的矩陣。)
xtset FID time
spmat use usaww using http://www.econometrics.it/stata/data/xsmle/usaww.spmat(生成空間權(quán)重矩陣,使用帶有變量LON(表示經(jīng)度)和LAT(表示緯度)的當前工作文件來創(chuàng)建矩陣的逆距離矩陣名)
xsmle?lngsp?lnpcap?lnpc?lnemp?spdid?t?code?,?fe?model(sac)?wmat(usaww)?emat(usaww)
spwmatrix import using queen.gal, wname(W) rowstand xport(新矩陣,dat)
(新矩陣,dat)可以用txt打開,然后導入excel,再轉(zhuǎn)換成dta