利用STATA创建空间权重矩阵及空间杜宾模型计算命令Word下载.docx
- 文档编号:13656393
- 上传时间:2022-10-12
- 格式:DOCX
- 页数:7
- 大小:15.67KB
利用STATA创建空间权重矩阵及空间杜宾模型计算命令Word下载.docx
《利用STATA创建空间权重矩阵及空间杜宾模型计算命令Word下载.docx》由会员分享,可在线阅读,更多相关《利用STATA创建空间权重矩阵及空间杜宾模型计算命令Word下载.docx(7页珍藏版)》请在冰豆网上搜索。
*database(filename):
SpecifiesfilenameofnewdBasedataset
*coordinates(coord):
创建一个名称为“coord”的坐标系数据集
*coordinates(filename):
Specifiesfilenameofnewcoordinatesdataset
*gencentroids(stub):
Createscentroidvariables
*genid(newvarname):
Createsuniqueidvariablefordatabase.dta
shp2dtausingCHN_adm1,database(chinaprovince)coordinates(coord)genid(id)gencentroids(c)
**绘制2016年中國GDP分布圖
*spmap:
Visualizationofspatialdata
*clnumber(#):
numberofclasses
*id(idvar):
basemappolygonidentifier(识别符,声明变量名,一般以字母或下划线开头,包含数字、字母、下划线)
*_2016GDP:
变量
*coord:
之前创建的坐标系数据集
spmap_2016GDPusingcoord,id(id)clnumber(5)
*更改变量名
renamex_clongitude
renamey_clatitude
**生成距离矩阵
*spmat:
用于定义与管理空间权重矩阵
*Spatial-weightingmatricesarestoredinspatial-weightingmatrixobjects(spmatobjects).
*spmatobjectscontainadditionalinformationaboutthedatausedinconstructingspatial-weightingmatrices.
*spmatobjectsareusedinfittingspatialmodels;
seespreg(ifinstalled)andspivreg(ifinstalled).
*idistance:
(产生距离矩阵)createanspmatobjectcontaininganinverse-distancematrixW
*或contiguity:
createanspmatobjectcontainingacontiguitymatrixW
*idistance_jingdu:
命名名称为“idistance_jingdu”的距離矩陣
*longitude:
使用经度
*latitude:
使用纬度
*id(id):
使用id
*dfunction(function[,miles]):
(设置计算距离方法)specifythedistancefunction.
*functionmaybeoneofeuclidean(default),dhaversine,rhaversine,ortheMinkowskidistanceoforderp,wherepisanintegergreaterthanorequalto1.
*normalize(row):
(行标准化)specifiesoneofthethreeavailablenormalizationtechniques:
row,minmax,andspectral.
*Inarow-normalizedmatrix,eachelementinrowiisdividedbythesumofrowi'
selements.
*Inaminmax-normalizedmatrix,eachelementisdividedbytheminimumofthelargestrowsumandcolumnsumofthematrix.
*Inaspectral-normalizedmatrix,eachelementisdividedbythemodulusofthelargesteigenvalueofthematrix.
spmatidistanceidistance_jingdulongitudelatitude,id(id)dfunction(euclidean)normalize(row)
**保存stata可读文件idistance_jingdu.spmat
spmatsaveidistance_jingduusingidistance_jingdu.spmat
**将刚刚保存的idistance_jingdu.spmat文件转化为txt文件
spmatexportidistance_jingduusingidistance_jingdu.txt
**生成相邻矩阵
spmatcontiguitycontiguity_jingduusingcoord,id(id)normalize(row)
spmatsavecontiguity_jingduusingcontiguity_jingdu.spmat
spmatexportcontiguity_jingduusingcontiguity_jingdu.txt
**计算Moran’sI
*安装spatwmat
*spatwmat:
用于定义空间权重矩阵
importsorgeneratesthespatialweightsmatricesrequiredbyspatgsa,spatlsa,spatdiag,andspatreg.
*Asanoption,spatwmatalsogeneratestheeigenvaluesmatrixrequiredbyspatreg.
*name(W):
读取空间权重矩阵W
使用生成的空间权重矩阵W
*xcoord:
x坐标
*ycoord:
y坐标
*band(08):
宽窗介绍
*band(numlist)isrequiredifoptionusingfilenameisnotspecified.
*Itspecifiesthelowerandupperboundsofthedistancebandwithinwhichlocationpairsmustbeconsidered"
neighbors"
(i.e.,spatiallycontiguous)
*and,therefore,assignedanonzerospatialweight.
*binary:
requeststhatabinaryweightsmatrixbegenerated.Tothisaim,allnonzerospatialweightsaresetto1.
spatwmat,name(W)xcoord(longitude)ycoord(latitude)band(08)
*安装绘制Moran’sI工具:
splagvar
*splagvar---Generatesspatiallylaggedvariables,constructstheMoranscatterplot,
*andcalculatesglobalMoran'
sIstatistics.
使用变量_2016GDP
*wname(W):
使用空间权重矩阵W
*indicatethenameofthespatialweightsmatrixtobeused
*wfrom(Stata):
indicatesourceofthespatialweightsmatrix
*wfrom(Stata|Mata)indicateswhetherthespatialweightsmatrixisaStatamatrixloadedinmemoryoraMatafilelocatedintheworkingdirectory.
*IfthespatialweightsmatrixhadbeencreatedusingspwmatrixitshouldexistasaStatamatrixorasaMatafile.
*moran(_2016GDP):
计算变量_2016GDP的Moran'
sI值
*plot(_2016GDP):
构建变量_2016GDPMoran散点图
splagvar_2016GDP,wname(W)wfrom(Stata)moran(_2016GDP)plot(_2016GDP)
**使用距离矩阵计算空间计量模型
cdD:
\软件学习软件资料\stata\stata指导书籍命令\陈强高级计量经济学及stata应用(第二版)全部数据
*使用product.dta数据集(陈强的高级计量经济学及其stata应用P594)
*将数据集product.dta存入当前工作路径
useproduct.dta,clear
*创建新变量,对原有部分变量取对数
genlngsp=log(gsp)
genlnpcap=log(pcap)
genlnpc=log(pc)
genlnemp=log(emp)
*将空间权重矩阵usaww.spat存入当前工作路径
spmatuseusawwusingusaww.spmat
*使用聚类稳健的标准误估计随机效应的SDM模型
xsmlelngsplnpcaplnpclnempunemp,wmat(usaww)model(sdm)robustnolog
*使用选择项durbin(lnemp),不选择不显著的变量,使用聚类稳健的标准误估计随机效应的SDM模型
xsmlelngsplnpcaplnpclnempunemp,wmat(usaww)model(sdm)durbin(lnemp)robustnolognoeffects
*使用选择项durbin(lnemp),不选择不显著的变量,使用聚类稳健的标准误估计固定效应的SDM模型
xsmlelngsplnpcaplnpclnemp
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 利用 STATA 创建 空间 权重 矩阵 模型 计算 命令