Spatial Economterics Using SMLE
Spatial Economterics Using SMLE
Federico Belotti? ,
Gordon Hughes , Andrea Piano Mortari?
Belotti, Hughes, Piano Mortari xsmle - Spatial Panel Data Models in Stata
Outline
1 Motivation
3 Examples
Estimation
Postestimation
Testing
Motivation
The xsmle command
Examples
References
n
X K
X K X
X n
yit = + yit 1 + wij yjt + xitk k + wij xjtk k +
j=1 k=1 k=1 j=1
+ i + t + it (1)
Xn
it = mij it + it i = 1, ..., n t = 1, ..., T (2)
j=1
Belotti, Hughes, Piano Mortari xsmle - Spatial Panel Data Models in Stata
Motivation
The xsmle command
Examples
References
shp2dta by K. Crow
spmat by D.M. Drukker et al
spwmatrix by P.W. Jeanty
spmap by M. Pisati
geocode3 by S. Bernhard
Panel data
spreg*xt suite SAR, SEM, SDM, SAC via LS, GLS, GMM or GS2SLS by E.A. Shehata
Belotti, Hughes, Piano Mortari xsmle - Spatial Panel Data Models in Stata
Motivation
The xsmle command
Examples
References
n
X
yit = wij yjt + 0.3x1it + 0.7x2it + i + t + it n = 1, . . . , 188 t = 1, . . . , 5
j=1
Belotti, Hughes, Piano Mortari xsmle - Spatial Panel Data Models in Stata
Motivation Options common to all spatial models
The xsmle command The weighting matrix
Examples Models specific options
References xsmle postestimation command
xsmle fits (balanced) Spatial Panel data models via maximum likelihood (ML)
Requirements:
(At least) Stata Version 10
The n n matrix of spatial weights. xsmle will deal with the longitudinal
dimension automatically
Data must be tsset or xtset
Belotti, Hughes, Piano Mortari xsmle - Spatial Panel Data Models in Stata
Motivation Options common to all spatial models
The xsmle command The weighting matrix
Examples Models specific options
References xsmle postestimation command
xsmle depvar indepvars if in weight , options
Belotti, Hughes, Piano Mortari xsmle - Spatial Panel Data Models in Stata
Motivation Options common to all spatial models
The xsmle command The weighting matrix
Examples Models specific options
References xsmle postestimation command
Belotti, Hughes, Piano Mortari xsmle - Spatial Panel Data Models in Stata
Motivation Options common to all spatial models
The xsmle command The weighting matrix
Examples Models specific options
References xsmle postestimation command
Belotti, Hughes, Piano Mortari xsmle - Spatial Panel Data Models in Stata
Motivation Options common to all spatial models
The xsmle command The weighting matrix
Examples Models specific options
References xsmle postestimation command
Variance estimation
This section describes the arguments of the vce(vcetype) option.
oim observed information matrix.
opg outer product of the gradient vectors.
robust clustered sandwich estimator where clustvar is the panelvar.
cluster clustvar clustered sandwich estimator.
dkraay(#) Driscoll-Kraay robust estimator. Where # is the maximum lag
used in the calculation.
Belotti, Hughes, Piano Mortari xsmle - Spatial Panel Data Models in Stata
Motivation Options common to all spatial models
The xsmle command The weighting matrix
Examples Models specific options
References xsmle postestimation command
a Stata matrix
a spmat object
Belotti, Hughes, Piano Mortari xsmle - Spatial Panel Data Models in Stata
Motivation Options common to all spatial models
The xsmle command The weighting matrix
Examples Models specific options
References xsmle postestimation command
SAR model
SDM model
Belotti, Hughes, Piano Mortari xsmle - Spatial Panel Data Models in Stata
Motivation Options common to all spatial models
The xsmle command The weighting matrix
Examples Models specific options
References xsmle postestimation command
SEM model
SAC model
GSPRE model
predict type newvar if in , statistic
where statistic includes:
rform the default, calculates predicted values from the reduced-form
equation: yit = (In W ) 1 (xit + i )
limited predicted values based on the limited information set. This
option is available only when model(sac).
naive predicted values based on the observed values of
yit = Wyit + xit + i
xb calculates the linear prediction including the fixed or random eect
xit + i .
a estimates i , the fixed or random-eect. In the case of fixed-eects
models, this statistic is allowed only when type(ind)
Belotti, Hughes, Piano Mortari xsmle - Spatial Panel Data Models in Stata
Motivation
Estimation
The xsmle command
Postestimation
Examples
Testing
References
n
X n
X
yit = 0.3 wij yjt + 0.5x1it 0.3x2it 0.2x3it + 0.3 wij x1it +
j=1 j=1
n
X n
X
+ 0.6 wij x2it + 0.9 wij x3it + i + t + it n = 1, ..., 188 t = 1, ..., 5
j=1 j=1
where k = 1, 2, 3, z1it is standard Gaussian, z2it is N(0, 1.52 ) and z3it is N(0, 22 ).
Belotti, Hughes, Piano Mortari xsmle - Spatial Panel Data Models in Stata
Motivation
Estimation
The xsmle command
Postestimation
Examples
Testing
References
Belotti, Hughes, Piano Mortari xsmle - Spatial Panel Data Models in Stata
Motivation
Estimation
The xsmle command
Postestimation
Examples
Testing
References
Log-likelihood = -1230.7734
------------------------------------------------------------------------------
y | Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
Main |
x1 | .5186041 .0364303 14.24 0.000 .4472019 .5900062
x2 | -.2946314 .0236541 -12.46 0.000 -.3409925 -.2482702
x3 | -.1923373 .0192912 -9.97 0.000 -.2301474 -.1545272
-------------+----------------------------------------------------------------
Wx |
x1 | .3772047 .075502 5.00 0.000 .2292235 .5251859
x2 | .5765484 .0449332 12.83 0.000 .4884809 .6646159
x3 | .8692021 .0372769 23.32 0.000 .7961408 .9422634
-------------+----------------------------------------------------------------
Spatial |
rho | .2519025 .0374278 6.73 0.000 .1785454 .3252596
-------------+----------------------------------------------------------------
Variance |
sigma2_e | .7915998 .0366863 21.58 0.000 .7196959 .8635037
-------------+----------------------------------------------------------------
[CONTINUES]
Belotti, Hughes, Piano Mortari xsmle - Spatial Panel Data Models in Stata
Motivation
Estimation
The xsmle command
Postestimation
Examples
Testing
References
Belotti, Hughes, Piano Mortari xsmle - Spatial Panel Data Models in Stata
Motivation
Estimation
The xsmle command
Postestimation
Examples
Testing
References
[CONTINUES]
-------------+----------------------------------------------------------------
Direct |
x1 | .5481382 .0362326 15.13 0.000 .4771237 .6191527
x2 | -.2642811 .0231199 -11.43 0.000 -.3095953 -.2189669
x3 | -.1422518 .0176968 -8.04 0.000 -.1769369 -.1075668
-------------+----------------------------------------------------------------
Indirect |
x1 | .6480929 .090572 7.16 0.000 .470575 .8256108
x2 | .6450951 .0599307 10.76 0.000 .5276331 .7625571
x3 | 1.050599 .058257 18.03 0.000 .9364176 1.164781
-------------+----------------------------------------------------------------
Total |
x1 | 1.196231 .1038425 11.52 0.000 .9927034 1.399759
x2 | .380814 .0677252 5.62 0.000 .2480751 .513553
x3 | .9083474 .0660288 13.76 0.000 .7789334 1.037761
------------------------------------------------------------------------------
. estimates store sdm_fe
Belotti, Hughes, Piano Mortari xsmle - Spatial Panel Data Models in Stata
Motivation
Estimation
The xsmle command
Postestimation
Examples
Testing
References
Log-likelihood = -1513.7006
------------------------------------------------------------------------------
y | Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
Main |
x1 | .6230976 .0408605 15.25 0.000 .5430126 .7031826
x2 | -.2439834 .0264129 -9.24 0.000 -.2957518 -.192215
x3 | -.1688081 .0211584 -7.98 0.000 -.2102778 -.1273385
_cons | -.0169191 .0811545 -0.21 0.835 -.1759791 .1421409
-------------+----------------------------------------------------------------
Wx |
x1 | .3706183 .0824133 4.50 0.000 .2090911 .5321454
x2 | .557779 .0493092 11.31 0.000 .4611347 .6544234
x3 | .8845199 .0411496 21.50 0.000 .8038681 .9651717
-------------+----------------------------------------------------------------
Spatial |
rho | .2472432 .0376366 6.57 0.000 .1734769 .3210096
-------------+----------------------------------------------------------------
Variance |
lgt_theta | -.3920581 .1040247 -3.77 0.000 -.5959428 -.1881735
sigma_e | 1.005536 .0528831 19.01 0.000 .9018867 1.109185
------------------------------------------------------------------------------
Belotti, Hughes, Piano Mortari xsmle - Spatial Panel Data Models in Stata
Motivation
Estimation
The xsmle command
Postestimation
Examples
Testing
References
Belotti, Hughes, Piano Mortari xsmle - Spatial Panel Data Models in Stata
Motivation
Estimation
The xsmle command
Postestimation
Examples
Testing
References
Log-likelihood = -1230.7734
------------------------------------------------------------------------------
y | Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
Main |
x1 | .5186041 .0364303 14.24 0.000 .4472019 .5900062
x2 | -.2946314 .0236541 -12.46 0.000 -.3409925 -.2482702
x3 | -.1923373 .0192912 -9.97 0.000 -.2301474 -.1545272
-------------+----------------------------------------------------------------
Wx |
x1 | .3772047 .075502 5.00 0.000 .2292235 .5251859
x2 | .5765484 .0449332 12.83 0.000 .4884809 .6646159
x3 | .8692021 .0372769 23.32 0.000 .7961408 .9422634
-------------+----------------------------------------------------------------
Spatial |
rho | .2519025 .0374278 6.73 0.000 .1785454 .3252596
-------------+----------------------------------------------------------------
Variance |
sigma2_e | .7915998 .0366863 21.58 0.000 .7196959 .8635037
------------------------------------------------------------------------------
Ho: difference in coeffs not systematic chi2(7) = 89.58 Prob>=chi2 = 0.0000
------------------------------------------------------------------------------
Belotti, Hughes, Piano Mortari xsmle - Spatial Panel Data Models in Stata
Motivation
Estimation
The xsmle command
Postestimation
Examples
Testing
References
. ********* Postestimation
. predict yhat, rform
. predict alphahat, a
Belotti, Hughes, Piano Mortari xsmle - Spatial Panel Data Models in Stata
Motivation
Estimation
The xsmle command
Postestimation
Examples
Testing
References
Belotti, Hughes, Piano Mortari xsmle - Spatial Panel Data Models in Stata
Motivation
Estimation
The xsmle command
Postestimation
Examples
Testing
References
Using matrix notation the SDM ( = 0) may be derived from a SEM model
y = X +u
{
u = Wu +
hence
u(1 W) =
y(1 W) = X (1 W) +
y = Wy + X WX +
y = Wy + X + WX +
Belotti, Hughes, Piano Mortari xsmle - Spatial Panel Data Models in Stata
Motivation
Estimation
The xsmle command
Postestimation
Examples
Testing
References
( 1) [Wx]x1 - [Wx]x2 = 0
( 2) [Wx]x1 - [Wx]x3 = 0
( 3) [Wx]x1 = 0
chi2( 3) = 740.80
Prob > chi2 = 0.0000
.
. ** Test for SEM
. testnl ([Wx]x1 = -[Spatial]rho*[Main]x1) ([Wx]x2 = -[Spatial]rho*[Main]x2) ([
> Wx]x3 = -[Spatial]rho*[Main]x3)
chi2(3) = 545.31
Prob > chi2 = 0.0000
Belotti, Hughes, Piano Mortari xsmle - Spatial Panel Data Models in Stata
Motivation
Estimation
The xsmle command
Postestimation
Examples
Testing
References
** SAC Model
. xsmle y x1 x2 x3, wmat(W) emat(W) model(sac) fe type(ind) noeff nolog
Log-likelihood = -1386.0860
------------------------------------------------------------------------------
y | Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
Main |
x1 | .3212791 .0341734 9.40 0.000 .2543005 .3882577
x2 | -.3135993 .0232111 -13.51 0.000 -.3590923 -.2681064
x3 | -.2997975 .0178884 -16.76 0.000 -.334858 -.2647369
-------------+----------------------------------------------------------------
Spatial |
rho | -.6676721 .0542468 -12.31 0.000 -.7739939 -.5613504
lambda | .8426981 .0209346 40.25 0.000 .801667 .8837293
-------------+----------------------------------------------------------------
Variance |
sigma2_e | 1.001782 .0440957 22.72 0.000 .9153562 1.088208
------------------------------------------------------------------------------
Belotti, Hughes, Piano Mortari xsmle - Spatial Panel Data Models in Stata
Motivation
Estimation
The xsmle command
Postestimation
Examples
Testing
References
-----------------------------------------------------------------------------
Model | Obs ll(null) ll(model) df AIC BIC
-------------+---------------------------------------------------------------
. | 940 . -1230.773 8 2477.547 2516.314
-----------------------------------------------------------------------------
Note: N=Obs used in calculating BIC; see [R] BIC note
-----------------------------------------------------------------------------
Model | Obs ll(null) ll(model) df AIC BIC
-------------+---------------------------------------------------------------
. | 940 . -1386.086 6 2784.172 2813.247
-----------------------------------------------------------------------------
Note: N=Obs used in calculating BIC; see [R] BIC note
Belotti, Hughes, Piano Mortari xsmle - Spatial Panel Data Models in Stata
Motivation
The xsmle command
Examples
References
Belotti, Hughes, Piano Mortari xsmle - Spatial Panel Data Models in Stata