日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

莫兰指数stata命令_一文读懂16个sp系列stata空间计量命令及应用

發布時間:2023/12/10 编程问答 38 豆豆
生活随笔 收集整理的這篇文章主要介紹了 莫兰指数stata命令_一文读懂16个sp系列stata空间计量命令及应用 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

原標題:一文讀懂16個sp系列stata空間計量命令及應用

在Stata 15中,推出了最新的空間計量官方命令,均以sp開頭,表示 spatial data),可以處理橫截面與面板形式的空間數據。本文主要為大家介紹空間計量命令。

一、命令匯總

1、Preparing data/數據準備

zipfile:Compress and uncompress files in zip archive format,表示壓縮和解壓縮zip存檔格式的文檔

spshape2dta:Translate shapefile to Stata format表示可以將 shapefile 文件轉換為 Stata 格式

spset:Declare data to be Sp spatial data聲明空間數據

spbalance:Make panel data strongly balanced使面板數據具有很強的平衡性

spcompress:Compress Stata-format shapefile壓縮數據成stata格式的shapefile

2、Looking at data/觀測數據

grmap:Graph choropleth maps繪制等值區域圖

spdistance:Calculator for distance between places計算區域之間距離

3、Setting the spatial weighting matrix/設置空間權重矩陣

spmatrix:Create, manipulate, and import/export weighting matrices表示創建操作管理、導入和導出空間權重矩陣

spgenerate:Generate spatial lag variables生成空間滯后變量

4、Fitting models/模型估計

spregress:Fit cross-sectional SAR models估計截面SAR模型

spivregress:Fit cross-sectional SAR models with endogenous covariates 估計工具變量SAR模型

spxtregress:Fit panel-data SAR models估計面板數據SAR模型

5、Postestimation/估計檢驗命令

estat moran:Moran's test after regress莫蘭指數檢驗

spregress postestimation:Postestimation tools for spregress截面SAR檢驗

spivregress postestimation:Postestimation tools for spivregress工具變量SAR檢驗

spxtregress postestimation:Postestimation tools for spxtregress面板SAR檢驗

2、操作應用介紹

首先導入并且下載homicide1990.dta和homicide1990_shp.dta ,其中homicide1990.dta表示的是具有相關變量的數據,而homicide1990_shp.dta是可以構建相關權重矩陣的數據,數據如下:

1、首先導入homicide1990數據,命令為:

use homicide1990

Convert the coordinates to latitude and longitude and measure the distance in miles

spset, modify coordsys(latlong, miles)

spmatrix命令簡介

spmatrix可以用來定義、創建、導入、導出空間權重矩陣,基本語法格式為:

spmatrix create contiguity spmatname [if] [in] [, contoptions stdoptions] spmatrix create idistance spmatname [if] [in] [, idistoption stdoptions]

其中spmatrix create contiguity W,此命令將根據相鄰關系(contiguity)來創建空間權重矩陣 ,而idistance 表示 inverse distance,將生成基于距離倒數的空間權重矩陣。

2、對于橫截面數據,估計截面SAR模型命令為spregress,語法格式為:

Generalized spatial two-stage least squares表示進行 GS2SLS 估計

spregress depvar [indepvars] [if] [in], gs2sls [gs2sls_options]

Maximum likelihood表示進行 MLE 估計

spregress depvar [indepvars] [if] [in], ml [ml_options]

(1)在spregress depvar [indepvars] [if] [in], gs2sls [gs2sls_options]表達式中,選項包括:

dvarlag(spmatname):spatially lagged dependent variable; repeatable表示指定被解釋變量(dependent variable)的空間權重矩陣

errorlag(spmatname):spatially lagged errors; repeatable,表示用于指定誤差項(error term)的空間權重矩陣。

ivarlag(spmatname : varlist):spatially lagged independent variables; repeatable/表示用于指定自變量(independent variable)的空間權重矩陣。

noconstant:suppress constant term

heteroskedastic:treat errors as heteroskedastic

level(#):set confidence level; default is level(95)表示設置置信水平,默認為95%

另外選擇項 robust 表示使用穩健標準誤。

(2)在spregress depvar [indepvars] [if] [in], ml [ml_options]

表達式中,包括的選項基本一致,區別之處在于ml方法不同。

3、工具變量法SAR模型估計命令為:spivregress,語法格式為:

spivregress depvar [varlist_1] (varlist_2 = varlist_iv) [if] [in] [, options]

選擇項包括ml gs2sls dvarlag(W) errorlag(W) ivarlag(W: x1 x2),含義與spregress一致。

4、面板SAR模型估計命令為:spxtregress,語法格式為:

Fixed-effects maximum likelihood

spxtregress depvar [indepvars] [if] [in], fe [fe_options]

Random-effects maximum likelihood

spxtregress depvar [indepvars] [if] [in], re [re_options]

選項包括如下:

dvarlag(spmatname):spatially lagged dependent variable

errorlag(spmatname):spatially lagged errors

ivarlag(spmatname : varlist):spatially lagged independent variables; repeatable

5、操作應用介紹

copy https://www.stata-press.com/data/r16/homicide_1960_1990.dta .

copy https://www.stata-press.com/data/r16/homicide_1960_1990_shp.dta

use homicide_1960_1990 //導入數據

xtset _ID year

spset

Create a contiguity weighting matrix with the default spectral normalization

spmatrix create contiguity W if year == 1990 //以1990年數據為基準構建空間權重矩陣

Fit a spatial autoregressive random-effects model

spxtregress hrate ln_population ln_pdensity gini i.year, re dvarlag(W)

//空間滯后模型回歸

Create an inverse-distance weighting matrix with the default spectral normalization

spmatrix create idistance M if year == 1990

Same as above but use the alternative formulation of the estimator

spxtregress hrate ln_population ln_pdensity gini i.year, re sarpanel dvarlag(M) errorlag(M)

Fit a spatial autoregressive fixed-effects model

spxtregress hrate ln_population ln_pdensity gini i.year, fe dvarlag(M) errorlag(M)

責任編輯:

總結

以上是生活随笔為你收集整理的莫兰指数stata命令_一文读懂16个sp系列stata空间计量命令及应用的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。