Spatial Modeling

Important note

In what follows, I describe some modules for spatial data that were available before Stata introduced their own sp commands for the analysis of spatial data in version 15.

As far as I can judge, the modules I describe here are still available and working. For information about the inbuilt sp commands, see Stata's help system (help sp will provide access to the introductory remarks and an overview of all available commands).



This entry is mainly about two classes of models: those provided by Maurizio Pisati's spatreg and those by spreg by David Drukker and collaborators. I will start, however, with the spatial diagnostics provided by Pisati.


Spatial diagnostics

Spatial diagnostics were developed mainly to test whether data analyzed via OLS regression exhibit spatial correlation. In other words, it is assumed that you just have estimated a linear regression model. Now,

spatdiag, weights(my-wmatrix)

will compute statistics that investigate spatial correlation among the residuals and help you judge whether a spatial lag or a spatial error model might be more appropriate.


Spatreg

Procedure spatreg requires a spatial weight matrix plus an eigenvalue vector pertaining to this matrix; both can be computed (if your data permit) by Pisani's spatwmat (see entry on spatial data).

spatreg can estimate spatial lag and spatial error models. The basic commands are:

spatreg depvar indepvars, weights(w-matrix) eigenval(e-vector) model(lag)

and

spatreg depvar indepvars, weights(w-matrix) eigenval(e-vector) model(error)


Spreg

Procedure spreg estimates a spatial-autoregressive model with spatial-autoregressive disturbances, offering two estimation methods. It requires two matrices, created by spmat, one for the spatial-autoregressive term and one for the spatial-error term. Both matrices can be (and often will be) identical, but have to be indicated both nevertheless.

The basis setup for model estimation is

spreg ml depvar indepvars, id(id-var) dlmat(w-matrix) elmat(w-matrix)

for maximum likelihood estimation, or

spreg gs2sls depvar indepvars, id(id-var) dlmat(w-matrix) elmat(w-matrix)

for generalized spatial two-stage least squares estimation.

id-var is an ID variable that was created by spmat, and the matrices provided with dlmat and elmat indicate the weights for the spatial-autoregressive and the error term, respectively.

© W. Ludwig-Mayerhofer, Stata Guide | Last update: 17 Aug 2016