空间面板双权重spm估计
计量经济学服务中心专辑汇总!计量百科·资源·干货:
Stata |Python |Matlab |Eviews |R Geoda |ArcGis |GeodaSpace |SPSS 一文读懂 |数据资源 |回归方法 |网络爬虫 门限回归 |工具变量 |内生性 |空间计量 因果推断 |合成控制法 |倾向匹配得分 |断点回归 |双重差分 面板数据 | 动态面板数据
空间面板双权重spm估计
简介
spm允许估计具有双权重矩阵的平衡空间面板数据模型,参考Atella V., Belotti F., Depalo D., Piano Mortari A., (2014), "Measuring spatial effects in the presence of institutional constraints: The case of Italian Local Health Authority expenditure", Regional Science and Urban Economics, 49, 232–241.
spm命令可以进行面板空间双权重矩阵的固定效应模型估计。
适用于平衡的面板数据,并且可以进行SAR, SEM和Durbin模型
语法格式
Spatial Autoregressive (SAR) model
spm depvar [indepvars] [if] [in] [weight] [, SAR_options]
Spatial Error (SEM) model
spm depvar [indepvars] [if] [in] [weight] , model(sem) [SEM_options]
Spatial Durbin (SDM) model
spm depvar [indepvars] [if] [in] [weight] , model(durbin) [DURBIN_options]
选项含义为:
sarwmat(name)表示 第一个用于空间自回归项的Stata权重矩阵
sarw2mat(name)表示 用于空间自回归项的第二个Stata权重矩阵
type(name) 表示固定效应类型可以是ind表示个体固定效果效果,time表示时间固定效果,或者both表示时间和个体固定效果
detrend表示去除单位特定的线性趋势
detrend quadratic表示去除单位特定的二次趋势
robust表示使用方差的鲁棒估计
level(#)表示设置置信度;默认为级别(95)
案例应用
首先我们先导入数据,该数据到地址为http://www.econometrics.it/stata/data/spm_demo.dta,我们先把该数据进行一个下载,然后导入数据,并且进行描述统计的查看。
命令如下,
. use "spm_demo.dta"
. summ
Variable | Obs Mean Std. dev. Min Max
-------------+---------------------------------------------------------
id | 940 94.5 54.29905 1 188
t | 940 3 1.414966 1 5
y | 940 15.24347 9.902384 .3007887 38.66438
x1 | 940 1.374253 1.19882 -2.039139 4.966914
. desc
Contains data from C:\Users\Metrics\Desktop\spm_demo.dta
Observations: 940
Variables: 4 25 Feb 2022 09:17
-----------------------------------------------------------------------------------------------------------------------------
Variable Storage Display Value
name type format label Variable label
-----------------------------------------------------------------------------------------------------------------------------
id float %9.0g
t float %9.0g
y float %9.0g
x1 float %9.0g
-----------------------------------------------------------------------------------------------------------------------------
Sorted by:
.
通过summ这个命令,我们可以对上述输入的数据进行分析。
这个数据里面y表示的是人均医疗的支出,x表示影响人均医疗支出的影响因素,就是非常重要的解释变量,然后t表示的是年份,即时间
通过分析,我们发现总共有940个观测值。
其实我们分别调用两个不同的空间权重矩阵来研究x对y的影响 。并且建立面板空间双重矩阵模型。
mata mata matuse "http://www.econometrics.it/stata/data/W1.mmat", replace
mata st_matrix("W1",W1)
mata mata matuse "http://www.econometrics.it/stata/data/W2.mmat", replace
mata st_matrix("W2",W2)
如下命令表示的是进行面板的一个设定。
xtset id t
现在我们来建立面板空间双权重矩阵模型
*Durbin model
spm y x1, model(durbin) sarwmat(W1) sarw2mat(W2)
*sar模型
spm y x1, model(sar) sarwmat(W1) sarw2mat(W2)
结果为:
. mata mata matuse "W1.mmat", replace
(loading W1[188,188])
.
. mata st_matrix("W1",W1)
.
. mata mata matuse "W2.mmat", replace
(loading W2[188,188])
.
. mata st_matrix("W2",W2)
. xtset id t
Panel variable: id (strongly balanced)
Time variable: t, 1 to 5
Delta: 1 unit
. *Durbin model
.
. spm y x1, model(durbin) sarwmat(W1) sarw2mat(W2)
Warning: All the specified regressors will be spatially lagged.
Iteration 0: Log-likelihood = -1876.7765 (not concave)
Iteration 1: Log-likelihood = -1550.9638
Iteration 2: Log-likelihood = -1377.7573
Iteration 3: Log-likelihood = -1323.3758
Iteration 4: Log-likelihood = -1319.3674
Iteration 5: Log-likelihood = -1319.338
SDM with spatial fixed effects Number of obs = 940
Group variable: id Number of groups = 188
Time variable: t Obs per group: min = 5
avg = 5.0
max = 5
Log-likelihood = -1319.3380
------------------------------------------------------------------------------
y | Coefficient Std. err. t P>|t| [95% conf. interval]
-------------+----------------------------------------------------------------
Main |
x1 | .4114542 .0340437 12.09 0.000 .3446214 .478287
-------------+----------------------------------------------------------------
Durbin |
x1 | .6014132 .0629448 9.55 0.000 .4778433 .7249832
-------------+----------------------------------------------------------------
Durbin2 |
x1 | .3211209 .0644323 4.98 0.000 .1946306 .4476111
-------------+----------------------------------------------------------------
Spatial |
rho | .2369618 .0216003 10.97 0.000 .1945571 .2793665
rho2 | .6739799 .0185239 36.38 0.000 .6376148 .710345
-------------+----------------------------------------------------------------
Variance |
sigma2 | 1.016058 .0381732 26.62 0.000 .9411178 1.090997
------------------------------------------------------------------------------
. *sar模型
.
. spm y x1, model(sar) sarwmat(W1) sarw2mat(W2)
Iteration 0: Log-likelihood = -2008.1247 (not concave)
Iteration 1: Log-likelihood = -1631.7851
Iteration 2: Log-likelihood = -1608.9731
Iteration 3: Log-likelihood = -1410.6768
Iteration 4: Log-likelihood = -1378.7923
Iteration 5: Log-likelihood = -1378.57
Iteration 6: Log-likelihood = -1378.5699
SLM with spatial fixed effects Number of obs = 940
Group variable: id Number of groups = 188
Time variable: t Obs per group: min = 5
avg = 5.0
max = 5
Log-likelihood = -1378.5699
------------------------------------------------------------------------------
y | Coefficient Std. err. t P>|t| [95% conf. interval]
-------------+----------------------------------------------------------------
Main |
x1 | .4335926 .0355193 12.21 0.000 .3638631 .503322
-------------+----------------------------------------------------------------
Spatial |
rho | .3062212 .0201995 15.16 0.000 .2665668 .3458756
rho2 | .6602167 .0177184 37.26 0.000 .625433 .6950004
-------------+----------------------------------------------------------------
Variance |
sigma2 | 1.120639 .0423002 26.49 0.000 1.037598 1.20368
------------------------------------------------------------------------------
参考文献
Cameron, A.C.,Gelbach, J.B.,Miller, D.L., 2011. Robust inference with multiway clustering. J. Bus. Econ. Stat. 29, 238–249.
LeSage, J.P.,Pace, R.K., 2009. Introduction to Spatial Econometrics. Taylor & Francis.
Rebonato, R., Jackel, P., 1999, The most general methodology to create a valid correlation matrix for risk management and option pricing purposes. Quantitative Research Centre of the NatWest G