1.输入命令:findit spatreg,在帮助文档上找到sg162 from
http://www.stata.com/stb/stb60,安装sg162
2.查阅帮助文档:
https://stats.idre.ucla.edu/stata/faq/how-can-i-calculate-morans-i-in-stata/
3.具体代码:help spatreg
use
https://stats.idre.ucla.edu/stat/stata/faq/ozone.dta, clear #示例数据
spatwmat, name(ozoneweights) xcoord(lon) ycoord(lat) band(0 3)
spatgsa av8top, weights(ozoneweights) moran
spatwmat using "C:\Users\Administrator\Desktop\1901195-320-变量计算\weights.dta", name(aweights)
use "C:\Users\Administrator\Desktop\1901195-320-变量计算\moran.dta"
spatgsa av8top, weights(aweights) moran