利用STATA创建空间权重矩阵及空间杜宾模型计算命令

合集下载
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

** 创建空间权重矩阵介绍

*设置默认路径

cd C:\Users\xiubo\Desktop\F182013.v4\F101994\sheng

**创建新文件

*shp2dta:reads a shape (.shp) and dbase (.dbf) file from disk and converts them into Stata datasets.

*shp2dta:读取CHN_adm1文件

*CHN_adm1:为已有的地图文件

*database (chinaprovince):表示创建一个名称为“chinaprovince”的dBase数据集

*database(filename):Specifies filename of new dBase dataset

*coordinates(coord):创建一个名称为“coord”的坐标系数据集

*coordinates(filename):Specifies filename of new coordinates dataset

*gencentroids(stub):Creates centroid variables

*genid(newvarname):Creates unique id variable for database.dta

shp2dta using CHN_adm1,database (chinaprovince) coordinates(coord) genid(id) gencentroids(c)

**绘制2016年中國GDP分布圖

*spmap:Visualization of spatial data

*clnumber(#):number of classes

*id(idvar):base map polygon identifier(识别符,声明变量名,一般以字母或下划线开头,包含数字、字母、下划线)

*_2016GDP:变量

*coord:之前创建的坐标系数据集

spmap _2016GDP using coord, id(id) clnumber(5)

*更改变量名

rename x_c longitude

rename y_c latitude

*spmat:用于定义与管理空间权重矩阵

*Spatial-weighting matrices are stored in spatial-weighting matrix objects (spmat objects).

*spmat objects contain additional information about the data used in constructing spatial-weighting matrices.

*spmat objects are used in fitting spatial models; see spreg (if installed) and spivreg (if installed).

*idistance:(产生距离矩阵)create an spmat object containing an inverse-distance matrix W

*或contiguity:create an spmat object containing a contiguity matrix W

*idistance_jingdu:命名名称为“idistance_jingdu”的距離矩陣

*longitude:使用经度

*latitude:使用纬度

*id(id):使用id

*dfunction(function[, miles]):(设置计算距离方法)specify the distance function.

*function may be one of euclidean (default), dhaversine, rhaversine, or the Minkowski distance of order p, where p is an integer greater than or equal to 1.

*normalize(row):(行标准化)specifies one of the three available normalization techniques: row, minmax, and spectral.

*In a row-normalized matrix, each element in row i is divided by the sum of row i's elements.

*In a minmax-normalized matrix, each element is divided by the minimum of the largest row sum and column sum of the matrix.

*In a spectral-normalized matrix, each element is divided by the modulus of the largest eigenvalue of the matrix.

spmat idistance idistance_jingdu longitude latitude, id(id) dfunction(euclidean) normalize(row)

**保存stata可读文件idistance_jingdu.spmat

spmat save idistance_jingdu using idistance_jingdu.spmat

**将刚刚保存的idistance_jingdu.spmat文件转化为txt文件

spmat export idistance_jingdu using idistance_jingdu.txt

相关文档
最新文档