help spivreg                                  also see:  spivreg postestimation


spivreg -- Spatial-autoregressive model with spatial-autoregressive erros and additional endogenous variables


spivreg depvar [varlist1] (varlist2 = [varlist_iv]) [if] [in], id(varname) [options]

options Description ------------------------------------------------------------------------- Model * id(varname) ID variable dlmat(name) spmat object used in the spatial-autoregressive term elmat(name) spmat object used in the spatial-error term noconstant suppress constant term heteroskedastic use the formula for the heteroskedastic error term impower(q) use q powers of matrix W in forming the instrument matrix H; default is 2

Maximization maximize_options control the maximization process; seldom used ------------------------------------------------------------------------- * Required


spivreg estimates the parameters of a cross-sectional spatial-autoregressive model with spatial-autoregressive disturbances which is known as a SARAR model when there are additional endogenous regressors.

A SARAR model includes a weighted average of the dependent variable, known as a spatial lag, as a right-hand-side variable and it allows the disturbance term to depend on a weighted average of the disturbances corresponding to other units. The weights may differ for each observation and are frequently inversely related to the distance from the current observation. These weights must be stored in a spatial-weighting matrix created by spmat.

spivreg estimates the parameters by generalized spatial two-stage least squares (GS2SLS).

You can download Drukker, Prucha, and Raciborski (2011), which documents this command, from


+-------+ ----+ Model +------------------------------------------------------------

id(varname) specifies a numeric variable that contains a unique identifier for each observation. This option is required.

dlmat(name) specifies an spmat object that contains the spatial-weighting matrix W to be used in the spatial-autoregressive term.

elmat(name) specifies an spmat object that contains the spatial-weighting matrix M to be used in the spatial-error term.

noconstant suppresses the constant term in the model.

heteroskedastic specifies that spivreg use an estimator that allows e to be heteroskedastically distributed over the observations. By default, spivreg uses an estimator that assumes homoskedasticity.

impower(q) specifies how many powers of the matrix W to include in calculating the instrument matrix H. Integers in the set {2, 3, ..., floor(sqrt(cols(W)))} are allowed, with q = 2 being the default.

+--------------+ ----+ Maximization +-----------------------------------------------------

maximize_options: iterate(#), [no]log, trace, gradient, showstep, showtolerance, tolerance(#), ltolerance(#), from(init_specs); see [R] maximize. These options are seldom used.


Setup . use pollute . spmat use cobj using pollute.spmat

Estimate the SARAR parameters . spivreg pollution area (factories = penalties), id(id) dlmat(cobj) elmat(cobj)

Saved results

spivreg saves the following in e():

Scalars e(N) number of observations e(k) number of parameters e(rho_2sls) initial estimate of rho e(iterations) number of GMM iterations e(iterations_2sls) number of 2SLS iterations e(converged) 1 if GMM stage converged, 0 otherwise e(converged_2sls) 1 if 2SLS stage converged, 0 otherwise

Macros e(cmdline) command as typed e(cmd) spivreg e(model) sarar, sar, sare, or lr e(het) heteroskedastic or homoskedastic e(title) title in estimation output e(depvar) name of dependent variable e(indeps) names of independent variables e(exogr) exogenous regressors e(insts) instruments e(instd) instrumented variables e(constant) noconstant or hasconstant e(H_omitted) names of omitted instruments in H e(idvar) name of ID variable e(dlmat) name of spmat object in dlmat() e(elmat) name of spmat object in elmat() e(predict) program used to implement predict e(estat_cmd) program used to implement estat e(properties) b V

Matrices e(b) coefficient vector e(V) variance-covariance matrix of the estimators e(delta_2sls) initial estimate of lambda and b

Functions e(sample) marks estimation sample


Drukker, D. M., I. R. Prucha, and R. Raciborski. 2011. A command for estimating spatial-autoregressive models with spatial autoregressive disturbances and additional endogenous variables. Working paper, The University of Maryland, Department of Economics,


David Drukker, StataCorp, College Station, TX.

Ingmar Prucha, Department of Economics, University of Maryland, College Park, MD.

Rafal Raciborski, StataCorp, College Station, TX.


We gratefully acknowledge financial support from the National Institute of Health through the SBIR grant R43 AG027622 and R44 AG027622.

Also see

Online: spmat, spreg, spmap, shp2dta, mif2dta (if installed)