-------------------------------------------------------------------------------
help for spmlreg 
-------------------------------------------------------------------------------

Title

spmlreg --- Estimates the spatial lag, the spatial error, the spatial durbin, and the general spatial models by maximum likelihood

+--------------------+ ----+ Table of Contents +-----------------------------------------------

Syntax General description Description of the options Saved Results Examples Acknowledgments Author information Citation

-------------------------------------------------------------------------------

Syntax

spmlreg varlist, weights(weights_name) wfrom(Stata|Mata) eignvar(varname) model(lag|error|durbin|sac) [Other_options]

options Description ------------------------------------------------------------------------- Options weights(weights_name) indicate the name of the spatial weights matrix to be used

wfrom(Stata|Mata) indicate the source of the spatial weights matrix eignvar(varname) indicate the name of the variable holding the eigenvalues of the weights matrix supplied with weigths()

model(lag|error|durbin|sac) indicate the model to be estimated

nolog suppress the iteration log

robust request Huber-White standard errors for the spatial lag or the spatial durbin model

level(#) specify the confidence level

favor(speed|space) favor speed or space

wrho(name) indicate the name of the weights matrix to be used to generate the spatially lagged dependent variable in the sac model

eigwrho(varname) specify the variable holding the eigenvalues of the weights matrix supplied with wrho(name)

initrho(#) provide initial value for rho

initlambda(#) provide initial value for lambda

sr2 display goodness of fit measures for the spatial lag, the spatial durbin, and the general spatial models

Other maximization_options specify other maximization options

-------------------------------------------------------------------------

+-------------+ ----+ Description +------------------------------------------------------

spmlreg estimates the spatial lag, the spatial error, the spatial durbin, and the general spatial (or spatial mixed) models by maximum likelihood. Optionally, at the end of the estimation process, predicted values of the dependent variable from the spatial lag, the spatial durbin, and the general spatial models are generated based on the expression for the conditional expectation of the reduced form since the spatially lagged dependent variable is endogenous.

Limitations: While the sample size that can be used is not subject to the matsize limit of your Stata flavor, unless you are running Small Stata, model estimation using huge datasets may be hampered by memory limitation since sparse matrix operations are not yet allowed in Mata. However, as long as you can generate a spatial weights matrix and a variable holding the eigenvalues using spwmatrix, spmlreg will dutifully estimate a model for you.

Dependency: spmlreg relies heavily on splagvar which must be installed.

+------------------+ ----+ Required options +-------------------------------------------------

weights(weights_name) specifies the name of the spatial weights matrix to be used in the estimation.

wfrom(Stata | Mata) indicates whether the spatial weights matrix is from Stata or Mata. If the spatial weights matrix is from Mata, the file should be located in the working directory. A spatial weights matrix created using spwmatrix should exist as a Stata matrix loaded in memory or as a Mata file.

eignvar(varname) indicates the name of the variable holding the eigenvalues of the weights matrix supplied with weigths(). This variable must have been generated using the eignvar() option of the spwmatrix command. Make sure the spatial weights matrix is row-standardized.

model(lag|error|durbin|sac) indicates the type of spatial model to be estimated. model(lag) estimates the spatial lag model, model(error) estimates the spatial error model, model(durbin) estimates the spatial durbin model, and model(sac) estimates the general spatial (or spatial mixed) model allowing for both lag and error autocorrelation.

+------------------+ ----+ Optional options +-------------------------------------------------

log and nolog specify whether an iteration log showing the progress of the log likelihood is to be displayed. The log is displayed by default, and nolog suppresses it.

robust requests Huber-White standard errors for the spatial lag and the spatial durbin models.

level(#) specifies the confidence level, in percent, for confidence intervals. The default is level(95) or as set by set level().

favor(speed|space) instructs spmlreg to favor speed or space when calculating several underlying spatially lagged variables. favor(speed) is the default. This option provides a tradeoff between speed and memory use. See [M-3] mata set.

wrho(name) indicates the name of the spatial weights matrix to be used when generating the spatially lagged dependent variable in the sac model. By default, the spatial weights matrix supplied with wname() is used for both the spatially lagged dependent variable and the spatially lagged disturbances, although there may be identification problems. The two spatial weights must be of the same source, as indicated with wfrom().

eigwrho(varname) specifies the variable holding the eigenvalues of the weights matrix supplies with wrho().

Note 1: Options wrho() and eigwhro() are necessary when you want to estimate the general spatial model with different spatial weights for the autoregressive lag and the autoregressive error terms. When these two options are not specified, spmlreg uses the same spatial weights matrix for both the autoregressive lag and the autoregressive error terms (see examples below).

initrho(#) provides initial value for rho. The default is initrho(0).

initlambda(#) provides initial value for lambda. The default is initlambda(0).

Note 2: You should rarely have to specify initrho(#) and initlambda(#)

sr2 requests that goodness of fit measures for the spatial lag, the spatial durbin, and the general spatial models be displayed. When this option is specified, two goodness of fit measures are reported. The first one is computed as the squared correlation between the predicted and observed values of the dependent variable. The other one is calculated as the ratio of the variance of the predicted values to the variance of the observed values of the dependent variable. As stressed above, for the spatial lag, the spatial durbin, and the general spatial models, spmlreg generates the predicted values from the expression for the conditional expectation of the reduced form:

y_hat = E(y|x) = (I-rho_hat*W)^-1 * X*beta_hat

By default, goodness of fit measures are calculated when you specify model(error). Note also that predicted values for the dependent variable in the spatial error model can be obtained using the predict command after estimation: . predict y_hat

Other maximization_options allows the user to specify other maximization options (e.g., difficult, trace, iterate(#), constraint(#), etc.). However, you should rarely have to specify them, though they may be helpful if parameters approach boundary values.

+---------------+ ----+ Saved Results +----------------------------------------------------

Depending on the model estimated, spmlreg saves the following results in e():

Scalars e(N) number of observations e(k) number of parameters e(k_eq) number of equations e(k_eq_model) number of equations to include in a model Wald test e(k_dv) number of dependent variables e(df_m) model degrees of freedom e(ll) log likelihood for the current model e(ll_0) log likelihood for OLS e(chi2) chi-squared e(p) significance of model of test e(ic) number of iterations e(rank) rank of e(V) e(rank0) rank of e(V) for OLS e(rc) return code e(converged) 1 if converged, 0 otherwise e(varRatio) variance ratio of predicted to observed values of the depe > ndent variable e(sqCorr) squared correlation between predicted and observed values > of the dependent variable e(wald_durbin) Wald test for the coefficients on the lags of X's e(p_durbin) p-value for the Wald test on the coefficients on lags of X > 's e(Wald) Wald test for rho or lambda equal to zero e(maxEigen) Maximum eigenvalue e(minEigen) minimum eigenvalue

Macros e(cmd) name of the command e(cmdline) command as typed e(depvar) name of the dependent variable e(pred_y) predicted values of dependent variable from the lag, durbi > n, and sac models e(title) title in estimation output e(chi2type) Wald or LR; type of model chi-squared test e(vce) vcetype specified in vce() e(vcetype) title used to label Std. Err. e(opt) type of optimization e(ml_method) type of ml method by commands using ml e(user) name of likelihood-evaluator program e(technique) from technique() option e(crittype) optimization criterion e(properties) estimator properties e(wname) name of the spatial weights matrix e(wfrom) source of the main spatial weights matrix: Mata or Stata

Matrices e(b) coefficient vector e(V) variance-covariance matrix of the estimators e(gradient) gradient vector e(ilog) iteration log (up to 20 iterations);

Functions e(sample) marks estimation sample

+----------+ ----+ Examples +---------------------------------------------------------

Load the Columbus crime dataset

. use http://fmwww.bc.edu/repec/bocode/c/columbus_dataset, clear

Import the first order contiguity spatial weights matrix, columbus.gal, created in GeoDa

. spwmatrix gal using http://fmwww.bc.edu/repec/bocode/c/columbus.gal, wn(W) eignvar(eigvarW) row mataf

-----------------------------------------------------------------------------

1) Estimate the spatial lag model

. spmlreg crime inc hoval, weights(W) wfrom(Mata) eignvar(eigvarW) model(lag) sr2

-----------------------------------------------------------------------------

2) Estimate the spatial error model

. spmlreg crime inc hoval, weights(W) wfrom(Mata) eignvar(eigvarW) model(error)

-----------------------------------------------------------------------------

3) Estimate the spatial durbin model

. spmlreg crime inc hoval, weights(W) wfrom(Mata) eignvar(eigvarW) model(durbin) sr2

-----------------------------------------------------------------------------

4) Estimate the general spatial model: y = rho*W*y + X*b + u, where u = lambda*W*u + e

. spmlreg crime inc hoval, weights(W) wfrom(Mata) eignvar(eigvarW) model(sac) sr2

-----------------------------------------------------------------------------

Create an inverse distance squared spatial weights matrix with a cutoff distance of 5 to be used for the lag autocorrelation

. spwmatrix gecon y x, wn(W1) cart rowstand wtype(inv) alpha(2) dband(0 5) eignvar(eigvarW1) mataf

5) Estimate the general spatial model: y = rho*W1*y + X*b + u, where u = lambda*W*u + e

. spmlreg crime inc hoval, weights(W) wfrom(Mata) eignvar(eignvarW) model(sac) wrho(W1) eigwrho(eigvarW1) sr2

-----------------------------------------------------------------------------

Note 3: For the Columbus crime dataset, spwmatrix can generate the weights matrix and the eigenvalues vector needed in order to use spatreg. You need to specify option eignval() and remove option mataf.

Acknowledgments

Thanks to Maurizio Pisati for writing spatreg. Thanks to Mark E. Schaffer for s > uggesting that I write spmlreg and for commenting on the first version.

Author

P. Wilner Jeanty, Dept. of Agricultural, Environmental, and Development Economics, The Ohio State University

Email to jeanty.1@osu.edu for any comments or suggestions.

Citation

Users should please cite spmlreg as follows:

Jeanty, P.W., 2010. spmlreg: Stata module to estimate the spatial lag, the spat > ial error, the spatial durbin, and the general spatial models.

Also see

Online: spatreg, sarml, spreg (if installed)