ImageVerifierCode 换一换
格式:DOCX , 页数:7 ,大小:15.67KB ,
资源ID:1772986      下载积分:1 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bingdoc.com/d-1772986.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(利用STATA创建空间权重矩阵及空间杜宾模型计算命令.docx)为本站会员(wj)主动上传,冰点文库仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰点文库(发送邮件至service@bingdoc.com或直接QQ联系客服),我们立即给予删除!

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

1、* 创建空间权重矩阵介绍*设置默认路径cd C:UsersxiuboDesktopF182013.v4F101994sheng*创建新文件*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 f

2、ilename 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) coordi

3、nates(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 longituderenam

4、e 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 sp

5、reg (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(funct

6、ion, 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, m

7、inmax, and spectral. *In a row-normalized matrix, each element in row i is divided by the sum of row is 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 t

8、he 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_j

9、ingdu 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*计算Morans I*安装spatwmat*spatwmat:用于定义空间权重矩阵*spatwmat:imports or generates th

10、e 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 sp

11、ecified. *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

12、 weights are set to 1.spatwmat, name(W) xcoord(longitude) ycoord(latitude) band(0 8)*安装绘制Morans I工具:splagvar*splagvar - Generates spatially lagged variables, constructs the Moran scatter plot, *and calculates global Morans I statistics.*_2016GDP:使用变量_2016GDP*wname(W):使用空间权重矩阵W *indicate the name of

13、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

14、 spwmatrix it should exist as a Stata matrix or as a Mata file.*moran(_2016GDP):计算变量_2016GDP的Morans I值*plot(_2016GDP):构建变量_2016GDPMoran散点图splagvar _2016GDP, wname(W) wfrom(Stata) moran(_2016GDP) plot(_2016GDP)*使用距离矩阵计算空间计量模型*设置默认路径cd D:软件学习软件资料statastata指导书籍命令陈强高级计量经济学及stata应用(第二版)全部数据*使用product.dta

15、数据集(陈强的高级计量经济学及其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(

16、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

17、 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 e

18、stimates *beta(fmt):display beta coefficients instead of point ests *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 l

19、abels *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

20、)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值,即chi20,表明模型不能满足Hausman检验的渐近假设。产生这些情况的原因可能有多种, *但我认为一个主要的原因是我们的模型设定有问题,导致Hausman 检验的基本假设得不到满

21、足。 *这时,我们最好先对模型的设定进行分析,看看是否有遗漏变量的问题,或者某些变量是非平稳的等等。 *在确定模型的设定没有问题的情况下再进行Hausman 检验,如果仍然拒绝原假设或是出现上面的问题, *那么我们就认为随机效应模型的基本假设(个体效应与解释变量不相关)得不到满足。 *此时,需要采用工具变量法或是使用固定效应模型。 *连玉君(论文(2014):Hausman检验统计量有效性的Monte Carlo模拟分析) *研究了hausman检验统计量的小样本性质,结果表明, *内生性问题(解释变量与个体效应相关)是导致hausman统计量出现负值的主要原因, *进一步分析表明,修正后的h

22、ausman统计量,以及过度识别检验方法能够很好地克服上述缺陷, *且具有很好的有限样本性质。 *陈强(高级计量经济学及其stata应用P153)介绍工具变量法与豪斯曼的stata命令及实例qui reg lw iq s expr tenure rns smsaest sto olsqui ivregress 2sls lw s expr tenure rns smsa (iq=med kww)est sto ivhausman iv o ls, constant sigmamore*由于传统的豪斯曼检验在异方差的情形下不成立,故进行异方差稳健的DWH检验,estat endogenous *

23、使用ivreg2检验选择的工具变量是否为内生解释变量ivreg2 lw s expr tenure rns smsa (iq=med kww),r endog(iq) *endog(iq)表示检验变量iq是否为内生变量*若果存在异方差,则GMM比2SLS更有效率,故进行最优GMM估计ivregress gmm lw s expr tenure rns smsa (iq=med kww)*进行过度识别检验estat overid *若P值不显著,则认为所有工具变量均为外生。*接下来考虑迭代GMMivregress gmm lw s expr tenure rns smsa (iq=med kww),igmm *(迭代GMM与两步GMM的系数估计值相差无几)

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2