【计量】空间杜宾模型代码

合集下载

空间计量经济学基本模型

空间计量经济学基本模型
* 参照时间序列自回归模型的叫法,空间滞后模型 也被称作空间自回归模型(Spatial Autoregressive Model),简记为SAR模型。
精品课件
➢空间误差模型(Spatial Error Model, SEM)
y X u u Wu
~ (0, 2I n )
* 参照时间序列误差自相关的叫法,空间误差模型 也被称作空间自相关模型(Spatial Autocorrelation Model),简记为SAC模型。
精品课件
问题:
练◦ 习考虑空间溢出效应的地区人均GDP影响因素 分析
数据文件:
◦ china.shp
论文提纲
◦ 全局MoranI检验 ◦ 局部Moran I检验 ◦ 回归分析 ◦ 运用三类不同的w分别做出结果,选最好的。
精品课件
精品课件
➢OLS、SLM、SEM的选择
Run OLS
精品课件
➢选择标准及步骤
✓1、做一次OLS估计
✓2、对比LM统计量,LM-Lag和LM-Error
✓3、若均不显著,则无需进行空间计量分析
✓4、若只有一个显著,则设定为与显著统计量 对应的空间计量模型
✓5、若均显著,再对比Robust LM-Lag和 Robust LM-Error
精品课件
➢空间杜宾误差模型(SDEM)
y W1y X1 W1X2 u u W2u ~ (0,2In)
* SDEM模型是SLM、SEM、SDM的综合,比GSAR更一般化。
* β2=0,λ=0,SDEMSLM; * β2=0,ρ=0,SDEMSEM; * λ=0,SDEMSDM;
* β2=0,SDEMGSAR;
精品课件
精品课件
精品课件

经济学中的空间计量模型

经济学中的空间计量模型

经济学中的空间计量模型一、空间计量模型概述空间计量模型是指将空间因素引入计量经济学模型中的一种方法。

空间计量模型通常用于研究空间相关性对经济现象的影响。

空间相关性是指位置相近的地区之间存在的相互依赖关系或者相互作用。

二、空间计量模型的基本形式空间计量模型的基本形式可以表示为:Y=ρWy + Xβ + ε其中,Y表示被解释变量,X表示非空间自变量,W表示空间自变量的邻接矩阵,ε代表误差项,ρ是空间相关系数,β是非空间自变量的系数。

空间自变量通常是指与地理位置有关的变量,比如距离、地理位置等。

三、空间计量模型的类别1. 空间自回归模型(Spatial Autoregression Model,SAR)SAR模型是最简单的空间计量模型之一。

SAR模型的核心思想是,与某一地区相邻的地区之间存在相互影响,这种影响可以通过在模型中引入空间自回归项来体现。

SAR模型通常用于研究空间依赖性的影响,比如一个地区的影响对相邻地区的经济发展状况的影响。

2. 空间误差模型(Spatial Error Model,SEM)SEM模型是一种常用的空间计量模型,其核心思想是每个地区的误差项受周围地区的误差项的影响。

SEM模型和SAR模型的区别在于,SEM模型中的空间相关性体现在误差项当中,而SAR模型中的空间相关性体现在自变量中。

3. 空间Durbin模型(SDM)SDM模型是SAR模型和SEM模型的综合体,其核心思想是同时考虑空间自回归和空间误差,在模型中引入两个空间因素项。

SDM模型通常用于研究空间因素对社会、经济现象的影响。

四、空间计量模型的应用场景空间计量模型有许多的应用场景,比如城市规划、环境保护、地区经济发展等领域。

1. 研究城市规划城市规划通常需要考虑到不同城市之间的相互依赖关系。

比如,周围地区的经济状况和城市的经济发展状况相关,不同城市之间的人口流动也会影响城市的规划。

这时候可以采用空间计量模型,来研究城市规划对相邻地区的影响。

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

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

** 创建空间权重矩阵介绍*设置默认路径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.dtashp2dta 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 longituderename 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 distanceof 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 rowsum 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.spmatspmat save idistance_jingdu using idistance_jingdu.spmat** 将刚刚保存的idistance_jingdu.spmat 文件转化为txt 文件spmat export idistance_jingdu using idistance_jingdu.txt** 生成相邻矩阵spmat contiguity contiguity_jingdu using coord, id(id) normalize(row)spmat save contiguity_jingdu using contiguity_jingdu.spmatspmat export contiguity_jingdu using contiguity_jingdu.txt** 计算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 mustbe 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 set 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 used*wfrom(Stata):indicate source of the spatial weights matrix*wfrom(Stata | Mata) indicates whether the spatial weights matrix is a Stata matrix loaded inmemory 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 matrixor as a Mata file.*moran(_2016GDP): 计算变量_2016GDP 的Moran's I 值*plot(_2016GDP): 构建变量_2016GDPMoran 散点图splagvar _2016GDP, wname(W) wfrom(Stata) moran(_2016GDP) plot(_2016GDP)=============================================================================== ** 使用距离矩阵计算空间计量模型*设置默认路径cd 软件学习软件资料\stata\stata 指导书籍命令陈强高级计量经济学及stata 应用(第二版)全部数据*使用product.dta 数据集(陈强的高级计量经济学及其stata 应用P594)*将数据集product.dta 存入当前工作路径use product.dta , clear*创建新变量,对原有部分变量取对数gen lngsp=log(gsp)gen lnpcap=log(pcap)gen lnpc=log(pc)gen lnemp=log(emp)*将空间权重矩阵usaww.spat 存入当前工作路径spmat use usaww using usaww.spmat*使用聚类稳健的标准误估计随机效应的SDM 模型xsmle lngsp lnpcap lnpc lnemp unemp,wmat(usaww) model(sdm)robust nolog*使用选择项durbin(lnemp) ,不选择不显著的变量,使用聚类稳健的标准误估计随机效应的SDM 模型xsmle lngsp lnpcap lnpc lnemp unemp,wmat(usaww) model(sdm) durbin(lnemp) robust nolognoeffects*使用选择项durbin(lnemp) ,不选择不显著的变量,使用聚类稳健的标准误估计固定效应的SDM 模型xsmle lngsp lnpcap lnpc lnemp unemp,wmat(usaww) model(sdm) durbin(lnemp) robust nolognoeffects fe*存储随机效应和固定效应结果qui xsmle lngsp lnpcap lnpc lnemp unemp,wmat(usaww) model(sdm) durbin(lnemp) r2 nolog noeffects reest sto requi xsmle lngsp lnpcap lnpc lnemp unemp,wmat(usaww) model(sdm) durbin(lnemp) r2 nolog noeffects feest sto fe*esttab: 将保存的结果汇总到一张表格中*b(fmt):specify format for point estimates*beta[(fmt)]:display beta coefficients instead of point est's*se[(fmt)]:display standard errors instead of t statistics*star( * 0.1 ** 0.05 *** 0.01): 标记不同显著性水平对应的P 值*r2|ar2|pr2[(fmt)]:display (adjusted, pseudo) R-squared*p[(fmt)]:display p-values instead of t statistics*label:make use of variable labels*title(string):specify a title for the tableesttab fe re , b se r2 star( * 0.1 ** 0.05 *** 0.01)*hausman 检验*进行hausman 检验前,回归中没有使用稳健标准误(没用“r”),*是因为传统的豪斯曼检验建立在同方差的前提下*constant:include estimated intercepts in comparison; default is to exclude*df(#):use # degrees of freedom*sigmamore:base both (co)variance matrices on disturbance variance estimate from efficient estimator*sigmaless:base both (co)variance matrices on disturbance variance estimate from consistent estimatorhausman fe re** 有时我们还会得到负的chi2 值,即chi2<0,表明模型不能满足Hausman 检验的渐近假设。

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

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

** 创建空间权重矩阵介绍*设置默认路径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.dtashp2dta 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 longituderename 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.spmatspmat save idistance_jingdu using idistance_jingdu.spmat**将刚刚保存的idistance_jingdu.spmat文件转化为txt文件spmat export idistance_jingdu using idistance_jingdu.txt**生成相邻矩阵spmat contiguity contiguity_jingdu using coord, id(id) normalize(row)spmat save contiguity_jingdu using contiguity_jingdu.spmatspmat export contiguity_jingdu using contiguity_jingdu.txt**计算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 set 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 used*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)=============================================================================== **使用距离矩阵计算空间计量模型*设置默认路径cd D:\软件学习软件资料\stata\stata指导书籍命令\陈强高级计量经济学及stata应用(第二版)全部数据*使用product.dta数据集(陈强的高级计量经济学及其stata应用P594)*将数据集product.dta存入当前工作路径use product.dta , clear*创建新变量,对原有部分变量取对数gen lngsp=log(gsp)gen lnpcap=log(pcap)gen lnpc=log(pc)gen lnemp=log(emp)*将空间权重矩阵usaww.spat存入当前工作路径spmat use usaww using usaww.spmat*使用聚类稳健的标准误估计随机效应的SDM模型xsmle lngsp lnpcap lnpc lnemp unemp,wmat(usaww) model(sdm)robust nolog*使用选择项durbin(lnemp),不选择不显著的变量,使用聚类稳健的标准误估计随机效应的SDM模型xsmle lngsp lnpcap lnpc lnemp unemp,wmat(usaww) model(sdm) durbin(lnemp) robust nolog noeffects*使用选择项durbin(lnemp),不选择不显著的变量,使用聚类稳健的标准误估计固定效应的SDM模型xsmle lngsp lnpcap lnpc lnemp unemp,wmat(usaww) model(sdm) durbin(lnemp) robust nolog noeffects fe*存储随机效应和固定效应结果qui xsmle lngsp lnpcap lnpc lnemp unemp,wmat(usaww) model(sdm) durbin(lnemp) r2 nolog noeffects reest sto requi xsmle lngsp lnpcap lnpc lnemp unemp,wmat(usaww) model(sdm) durbin(lnemp) r2 nolog noeffects feest sto fe*esttab:将保存的结果汇总到一张表格中*b(fmt):specify format for point estimates*beta[(fmt)]:display beta coefficients instead of point est's*se[(fmt)]:display standard errors instead of t statistics*star( * 0.1 ** 0.05 *** 0.01):标记不同显著性水平对应的P值*r2|ar2|pr2[(fmt)]:display (adjusted, pseudo) R-squared*p[(fmt)]:display p-values instead of t statistics*label:make use of variable labels*title(string):specify a title for the tableesttab fe re , b se r2 star( * 0.1 ** 0.05 *** 0.01)*hausman检验*进行hausman检验前,回归中没有使用稳健标准误(没用“r”),*是因为传统的豪斯曼检验建立在同方差的前提下*constant:include estimated intercepts in comparison; default is to exclude*df(#):use # degrees of freedom*sigmamore:base both (co)variance matrices on disturbance variance estimate from efficient estimator*sigmaless:base both (co)variance matrices on disturbance variance estimate from consistent estimatorhausman fe re**有时我们还会得到负的chi2值,即chi2<0,表明模型不能满足Hausman检验的渐近假设。

异质型环境规制对雾霾污染的影响——基于空间杜宾模型

异质型环境规制对雾霾污染的影响——基于空间杜宾模型

近年来,雾霾污染的大面积常态化爆发严重影响了我国经济的可持续发展、公众健康和政府形象,加快治理雾霾污染已成为政府和民众关注的热点话题。

2013年1月,全国发生了四次严重雾霾污染事件,北京仅有五天不是雾霾天,东北地区雾霾污染甚至导致当地公共交通瘫痪,给民众的正常出行带来极大阻碍[1]。

2016年,我国338个地级及以上城市中,75.1%的城市空气质量超标,尤其是京津冀地区雾霾污染最为严重[2]。

雾霾天气会导致居民患呼吸、心脑血管等疾病的概率大大上升,甚至引发癌症,公众对空气污染可能带来的健康风险强烈关注[3-4]。

2017年我国环境保护部门受理的群众举报案件中,大气举报案达到案件总数的近六成[5]。

由于环境的公共物品属性和雾霾污染的空间溢出效应,仅仅依靠市场调节很难起到满意的治理效果。

因此,为了打赢蓝天保卫战,推动经济可持续健康发展,我们必须根据国情制定科学的雾霾治理政策,实行具有针对性的环境规制措施。

那么不同类型的环境规制工具是否以及如何影响雾霾污染?如何优化这些规制工具组合效应以更好地治理雾霾?针对这些问题,本文基于2000—2017年我国大陆地区(不含西藏)的省域面板数据,构建空间杜宾模型对异质型环境规制如何影响我国雾霾污染进行实证研究,以期为我国雾霾治理提供一些重要信息。

收稿日期:2021-01-05本刊网址·在线期刊:http :///jhxs基金项目:全国统计科学研究项目“高质量发展视角下海洋生态福利绩效测度与提升路径研究”(2020LY03);山东省社科规划项目“新时代山东省产业转型升级与生态文明建设融合发展研究”(18CJJJ32);青岛市社科规划项目“青岛市生态文明建设与产业结构转型升级协调发展研究”(QDSKL2001064)作者简介:陈东景,男,山东成武人,青岛大学经济学院教授,博士生导师,E-mail :***************;冷伯阳,女,陕西西安人,青岛大学经济学院硕士生,E-mail :****************。

利用Stata命令进行空间杜宾模型分析

利用Stata命令进行空间杜宾模型分析

利用Stata命令进行空间杜宾模型分析标题:利用Stata命令进行空间杜宾模型分析介绍:在空间计量经济学领域,空间杜宾模型(Spatial Durbin Model)被广泛应用于探究空间依赖关系对经济现象的影响。

Stata作为一款常用的统计软件,提供了许多强大的命令来进行空间经济分析。

本文将介绍如何利用Stata命令进行空间杜宾模型的分析和解释。

一、概述空间杜宾模型是对传统杜宾模型的扩展,考虑了空间上的相互依赖关系。

其基本方程可以表示为:Y = ρWy + Xβ + λU + ε其中,Y是因变量,Wy表示空间邻近权重矩阵与因变量的乘积,X是自变量矩阵,β是参数向量,U是随机误差项,ε是空间误差项。

ρ和λ分别代表空间滞后和同时方程的空间依赖系数。

二、数据准备在Stata中进行空间杜宾模型的分析,首先要准备好需要的数据。

可以使用Stata的数据管理命令进行数据导入和转换,确保数据的一致性和准确性。

还需考虑到空间邻近权重矩阵的构建,可以使用Stata的空间数据分析命令来计算邻近矩阵。

三、模型估计利用Stata进行空间杜宾模型的估计,可以使用"splm"命令。

该命令提供了多种空间经济模型的估计方法,包括最小二乘法(OLS)、广义矩估计法(GMM)等。

在使用"splm"命令时,需要设定模型的形式和变量的选择。

四、模型诊断和解释为了确保模型的有效性和准确性,需要对模型进行诊断和解释。

可以通过Stata的模型诊断命令来进行一系列统计分析,如异方差性检验、空间误差的显著性检验等。

还可以使用Stata的模型解释命令来获取模型估计结果的解释,并进行进一步的分析和讨论。

五、实证案例分析在本节中,将以一个实证案例来展示如何使用Stata命令进行空间杜宾模型的分析。

案例数据为某地区的经济数据,包括GDP、人口、贸易等变量。

我们希望研究空间依赖对GDP的影响,并通过空间杜宾模型来分析这一关系。

计量经济学软件Stata15.0应用教程 课件 第九章 空间计量

计量经济学软件Stata15.0应用教程  课件 第九章  空间计量
spatlsa crime,w(M) moran twotail //49个社区的局部莫兰指数I及检验结果 spatlsa crime,w(M) geary twotail //49个社区的局部吉尔里指数C及检验结果 spatlsa crime,w(M) go twotail //49个社区的局部Getis-Ord指数及检验结果 spatlsa crime,w(M) moran geary go twotail
hausman FE RE
( 1) 极大似然估计 spreg ml crime hoval income,id(id) dlm (A) elm (A) //MLE估计SARAR模型
( 2) 不含内生变量的gs2sls估计 spreg gs2sls crime hoval income, id(id) dlm (A) elm (A) het //GS2SLS估计SARAR模型 spreg gs2sls crime hoval income, id(id) dlm (A) het //不含空间误差的SAR模型 het(异方差 下的稳健标误)
spmat use B using usaww.spmat //用数据文件usaww.spmat生成空间权重矩阵B
SDM模型:
xsmle lngsp lnpcap lnpc lnemp unemp,wmat(B) model (sdm) r //随机效应估计 xsmle lngsp lnpcap lnpc lnemp unemp,wmat(B) model (sdm) durbin (lnemp) r //空间杜宾模型 xsmle lngsp lnpcap lnpc lnemp unemp,wmat(B) model (sdm) durbin (lnemp) r noeffe //固定效应 hausman检验:

空间计量模型stata代码

空间计量模型stata代码

空间计量模型stata代码
空间计量模型stata代码是一种用于空间数据分析的统计软件,在stata中可以进行空间计量模型的建模和分析。

具体的代码包括以下几个步骤:
1.导入数据:使用stata命令“use”或者“import”导入需要分析的数据集。

2.定义空间权重矩阵:使用stata命令“spmat”或者“spwmatrix”定义空间权重矩阵,用于描述空间上的邻近关系。

3.空间回归模型建模:使用stata命令“spreg”或者“spatialreg”建立空间回归模型,其中包括空间滞后模型、空间错误模型、空间滞后误差模型等。

4.模型诊断和评价:使用stata命令“spatdiag”或者“sppack”对建立的空间回归模型进行诊断和评价,包括空间自相关性检验、异方差性检验、模型拟合度评价等。

5.结果分析和可视化:使用stata命令“spmap”或者“spgraph”对分析结果进行可视化展示,以便更好地理解和解释分析结果。

总之,空间计量模型stata代码是一种非常重要的工具,可以帮助研究者更好地理解和分析空间数据,并为相关领域的研究提供支持和帮助。

- 1 -。

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

空间杜宾模型stata代码
clear all
cd "F:\stata14\ado\mydo\agglo"
**调入权重矩阵
use Wqiantaoinver.dta, clear
keep s*
save "W2.dta" ,replace
**矩阵转换为stata应用格式
spatwmat using W2, name(W)standardize
matrix list W
***调入数据
use data11.21.dta, clear
*对数生成
gen lnii=ln(ii)
gen lnp=ln(p)
gen lna=ln(a)
gen lnt=ln(t)
gen lnc=ln(c)
*设定面板数据格式
xtset id year
**变量描述性统计
local x " ii c p a t" //5个变量
tabstat `x', s(mean sd min p25 p50 p75 max) ///
format(%6.4f) c(s)
*****(2)estimation
****SDM estimation(个体固定ind)
//Spatial Durbin model (SDM)
xsmle lnii lnc lnp lna lnt, wmat(W) model(sdm) fe type(ind) nsim(500) nolog effects
est store M_sptial //不要加入c三次方lna_2,使用第三产业,加入c_lng交乘项
estat ic //AIC BIC test
//Spatial Durbin model (时间固定time)
xsmle lnii lnc lnp lna lnt, wmat(W) model(sdm) fe type(time) nsim(500) nolog effects est store M_time
estat ic
//Spatial Durbin model(双固定,both)
xsmle lnii lnc lnp lna lnt , wmat(W) model(sdm) fe type(both) nsim(500) nolog effects est store M_both
estat ic
**结果汇总列表显示
local m "M_sptial M_time M_both"
esttab `m', mtitle(`m') nogap s(r2 ll aic bic N ) ///
star(* 0.1 ** 0.05 *** 0.01) b(%6.3f)
esttab M_sptial M_time M_both using pane0000.rtf //输出结果rtf excel doc
****hausman test
xsmle lnii lnc lnp lna lnt , wmat(W) model(sdm) fe type(both) nsim(500) nolog estimates store sdm_fe
xsmle lnii lnc lnp lna lnt , wmat(W) model(sdm) re type(both) nsim(500) nolog estimates store sdm_re
hausman sdm_fe sdm_re。

相关文档
最新文档