-------------------------------------------------------------------------------help for anketest-------------------------------------------------------------------------------

Title

anketest---Performs diagnostic tests for spatial autocorrelation in the residuals from OLS, SAR, IV, and IV-SAR models+--------------------+ ----+ Table of Contents +-----------------------------------------------

Syntax General description Description of the options Important remarks Examples References Citation Author information -------------------------------------------------------------------------------

anketest,wname(wght_name)wfrom(Stata|Mata)model(ols|sar|iv|iv-sar)[favor(speed|space)]

optionsDescription ------------------------------------------------------------------------- Optionswname(wght_name)indicate the name of the spatial weights matrix to be used

wfrom(Stata|Mata)indicate the source of the spatial weights matrix

model(ols|sar|iv|iv-sar)indicate the estimated model

favor(speed|space)favor speed or space

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

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

anketestcarries out diagnostic tests for spatial autocorrelation in the residuals from Ordinary Least Squares (OLS), spatial autoregressive (SAR), and instrumental variable regressions with or without a spatially lagged dependent variable (IV-SAR or IV). A spatial weights matrix, which may exist as a Stata matrix loaded in memory or as a Mata file located in the working directory, is required.

anketestrequires Stata 9.2 or higher.

+---------+ ----+ Options +----------------------------------------------------------

wname(wght_name)specifies the name of the spatial weights matrix to be used.

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

model(ols|sar|iv|iv-sar)indicates the model for which the residuals need to be tested. Specifyingmodel(ols)implies a model estimated using the regress command.model(sar)implies a model containing a spatially lagged dependent variable estimated by spatial two-stage least squares (2SLS) using the Stata's official command ivregress or the user-written command ivreg29. TheSARmodel may have also been estimated by maximum likelihood using the user-written command spmlreg.model(iv)suggests a model estimated with (non-spatial) endogenous regressors, but without a spatially lagged dependent variable.model(iv-sar)indicates a model containing both (non-spatial) endogenous variables and a spatially lagged dependent variable. The command ivregress, or ivreg29 must have been used to estimate theivmodel by 2SLS and theiv-sarmodel by spatial 2SLS. For model estimation by spatial 2SLS inStatasee splagvar.

favor(speed|space)instructsanketestto favor speed or space when calculating the test statistics.favor(speed)is the default. This option provides a tradeoff between speed and memory use. See [M-3] mata set.+-------------------+ ----+ Important remarks +------------------------------------------------

When testing the residuals from a spatial lag model estimated by maximum likelihood (ML), two spatial weights, which may be the same or different, are required, one for each spatial dependence structure (lag and error). If the name of the spatial weights matrix supplied to spmlreg with

weights()for the estimation of the spatial lag model is the same as that of the spatial weights matrix specified withwname(), then that spatial weights matrix will be used for both structures. Otherwise,anketestwill use the spatial weights matrix supplied to spmlreg withweights()for the lag structure and the spatial weights matrix specified withwname()for the error structure.

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

1) Test for spatial autocorrelation in the residuals from an OLS model

. anketest, wname(mywght) wfrom(Mata) model(ols)-----------------------------------------------------------------------------

2) Test for spatial autocorrelation in the residuals from an IV model

. anketest, wname(mywght) wfrom(Mata) model(iv)-----------------------------------------------------------------------------

3) Test for spatial autocorrelation in the residuals from a model containing non-spatial endogenous right-handside variables and a spatially lagged dependent variable

. anketest, wname(mywght) wfrom(Mata) model(iv-sar)

Anselin, L., 2007. "Spatial Econometrics." In T. C. Mills and K. Patterson (Eds > ).Palgrave Handbook of Econometrics. Vol 1, Econometric Theory. New York: Palgrave MacMillan, pp. 901-969.

Anselin, L., 2001.Spatial Econometrics. In Baltagi, B. (Ed).A Companion to Th> eoretical Econometrics. Basil Blackwell: Oxford, UK, 310-330.

Anselin, L., 1988.Spatial Econometrics: Methods and Models. Kluwer Academic Pu > blishers, Dordrecht, The Netherlands.

Anselin, L., Kelejian, H. H., 1997. Testing for Spatial Error Autocorrelation i > n the Presence of Endogenous Regressors.International Regional Science Review20, 153-182.

Users should please cite anktest as:

Jeanty, P.W., 2010. anketest: Stata module to perform diagnostic tests for spat > ial autocorrelation in the residuals from OLS, SAR, IV, and IV-SAR models. Available from ideas.repec.org/c/boc/bocode/s457113.html.

P. Wilner Jeanty, Dept. of Agricultural, Environmental, and Development Economics, The Ohio State UniversityEmail to jeanty.1@osu.edu for any comments or suggestions.

Also see