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

更新时间:2023-06-04 03:53:53 阅读: 评论:0

** 创建空间权重矩阵介绍
*设置默认路径
cd C:\Urs\xiubo\Desktop\F182013.v4\F101994\sheng
**创建新文件
*shp2dta:reads a shape (.shp) and dba (.dbf) file from disk and converts them into Stata datats.
*shp2dta:读取CHN_adm1文件
*CHN_adm1:为已有的地图文件
*databa (chinaprovince):表示创建一个名称为“chinaprovince”的dBa数据集
*databa(filename):Specifies filename of new dBa datat
*coordinates(coord):创建一个名称为“coord”的坐标系数据集
*coordinates(filename):Specifies filename of new coordinates datat
克服困难的名言*gencentroids(stub):Creates centroid variables
*genid(newvarname):Creates unique id variable for databa.dta
shp2dta using CHN_adm1,databa (chinaprovince) coordinates(coord) genid(id) gencentroids(c)
**绘制2016年中國GDP分布圖
*spmap:Visualization of spatial data
*clnumber(#):number of class
*id(idvar):ba 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 ud in constructing spatial-weighting matrices.
*spmat objects are ud in fitting spatial models; e spreg (if installed) and spivreg (if ins
talled).
*idistance:(产生距离矩阵)create an spmat object containing an inver-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 technique
s: 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
**生成相邻矩阵
spmat contiguity contiguity_jingdu using coord, id(id) normalize(row)
spmat save contiguity_jingdu using contiguity_jingdu.spmat
spmat export contiguity_jingdu using
艾草粿**计算Moran’s I
*安装spatwmat
*spatwmat:用于定义空间权重矩阵
*spatwmat:imports or generates the spatial weights matrices required by spatgsa, spatlsa, spatdiag, and spatreg.
*As an option, spatwmat also generates the eigenvalues matrix required by spatreg.
*name(W):读取空间权重矩阵W
北字成语
*name(W):使用生成的空间权重矩阵W
*xcoord:x坐标
*ycoord:y坐标
节俭悖论*band(0 8):宽窗介绍
*band(numlist) is required if option using filename is not specified.
*It specifies the lower and upper bounds of the distance band within which location pairs must be considered "neighbors" (i.e., spatially contiguous)
*and, therefore, assigned a nonzero spatial weight.
*binary:requests that a binary weights matrix be generated. To this aim, all nonzero spatial weights are t to 1.
凉州词其一spatwmat, name(W) xcoord(longitude) ycoord(latitude) band(0 8)
*安装绘制Moran’s I工具:splagvar
*splagvar --- Generates spatially lagged variables, constructs the Moran scatter plot,
*and calculates global Moran's I statistics.
*_2016GDP:使用变量_2016GDP
*wname(W):使用空间权重矩阵W
*indicate the name of the spatial weights matrix to be ud
*wfrom(Stata):indicate source of the spatial weights matrix
*wfrom(Stata | Mata) indicates whether the spatial weights matrix is a Stata matrix loaded in memory or a Mata file located in the working directory.
*If the spatial weights matrix had been created using spwmatrix it should exist as a Stata
matrix or as a Mata file.
*moran(_2016GDP):计算变量_2016GDP的Moran's I值
*plot(_2016GDP):构建变量_2016GDPMoran散点图
splagvar _2016GDP, wname(W) wfrom(Stata) moran(_2016GDP) plot(_2016GDP)
**使用距离矩阵计算空间计量模型

本文发布于:2023-06-04 03:53:53,感谢您对本站的认可!

本文链接:https://www.wtabcd.cn/fanwen/fan/82/855507.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

标签:矩阵   空间   权重   文件   使用
相关文章
留言与评论(共有 0 条评论)
   
验证码:
推荐文章
排行榜
Copyright ©2019-2022 Comsenz Inc.Powered by © 专利检索| 网站地图