*** Addition to the README.TXT File *** by Rob Vigfusson. 11 October 1999 I added a program xgmlt.ado to estimate a logit model with standard errors corrected for spatial correlation. In design, the programs are very similar to those described below. The logit parameters are created by the STATA logit command. *********** Stata Code to Estimate Spatial GMM ******************* by Jean Pierre Dube _____________________________________________________________________________ This document summarizes the programs available for correcting for spatial correlation using STATA (version 5.0 or better). If you already have coordinates for your spatial data, you may directly run the programs: x_ols.ado and x_gmm.ado If you have distances, not coordinates, you will need to create the coordinates. You may use the mutlidimensional scaling program: scale.ado The `ado' files are commands you can invoke while in STATA. Some sample `do' files are available to show how to create a STATA program that will invoke these `ado' files. ----------------------------------------------------------------------------- 1) MULTIDIMENSIONAL SCALING ----------------------------------------------------------------------------- While in STATA, you can generate a coordinate system from a distance matrix using scale.ado. Occasionally, the notion of distance used may not correspond directly to a Euclidean coordinate system. This procedure allows the user to take any set of distances between points and use a procedure called multidimensional scaling to obtain a set of coordinates in a Euclidean space (of specified dimension) whose interpoint distances approximate the original distances between points. To use this command, you need to have very specific input data. Each element of your distance matrix must be formatted as a separate observation. So each observation must have three variables: the row position, the column position and the distance associated with the distance matrix. Suppose you name these three variables "row", "col" and "dist." To invoke the scale command, simply type: >>scale row col dist, dim(positive integer) where dim is the dimension of the coordinate system you want to create. You must specify a positive integer for the dim() option. The command will output a vector of eigenvalues, a matrix of eigenvectors, coordinate vectors (the number of which corresponds to the choice of dim()) and two measures of goodness-of-fit. The program demo_mds.do can be used to run the scale procedure. It reads an input file called mds_input.dat with the variables row, column and distance. The program will read the file, run the scale procedure and save the coordinate vectors in a STATA file called coords.dat. ------------------------------------------------------------------------------- 2) Spatial GMM and Spatial OLS ------------------------------------------------------------------------------- Once you have a set of coordinates for your points you can procede with estimation. The next problem will be to correct the standard errors of your parameter coefficients for possible serial dependence based on location. Two estimation procedures are available: OLS and GMM. The input variables for these procedures are fairly specific. In addition to the dependent variable, the regressor list and (in the gmm case) the instrument list, you also need a separate variable for each coordinate. So if you have a three-dimensional coordinate system, you will need three coordinate variables. Finally, asymptotic covariance matrices for moment conditions are estimated as weighted averages of sample autocovariances. The weight for each term is the product of weight functions in each dimension that decline linearly and are zero beyond a cutoff number. Thus you will need to supply a list of cutoff variables, one for each coordinate. These cutoffs are analogous to the cutoff number for a Newey-West covariance matrix estimator for time series. The two procedures also have some additional parameters detailed below. A)x_ols.ado: This command estimates the simple OLS regression model and outputs parameter estimates with spatial std errors and heterskedasticity consistent std errors for comparison. To use this command, in STATA type: >>x_ols coordlist cutlist dep regressors, coord() xreg() The options coord() and xreg() are mandatory and take a postive integer as their arguments. Coord() refers to the number of coordinate variables (dimension of coordinates) and xreg() refers to the number of regressors. B)x_gmm.ado: This command estimates a linear model with instruments via GMM. In Output is GMM parameter estimates, standard errors (corrected for spatial dependence) and test of overidentifying restrictions. Two-stage least squares regression (assuming spatial independence) are also output. To use this command, in STATA type: >>x_gmm coordlist dep regressors, coord() xreg() inst() The options coord() and xreg() are the same as in the x_ols command. The inst() option gives the number of instruments used (the number of moment restrictions). NOTE: the instrument list and the regressor list may have variables in common! C) examples: The `do' files demo_ols.do and demo_gmm.do have been created to show how both the ols and gmm procedures work. demo_ols.do reads an ascii input file called data_ols.dat. This file has a 2-dimensional coordinate system, the dependent variable and 1 regressor. The file creates a constant term, two cutoffs and then runs the ols procedure. demo_gmm.do reads an ascii input file called data_gmm.dat. This file has a 2-dimensional coordinate system, the dependent variable, 1 regressor and two instruments. The file creates a constant term, two cutoffs and then runs the gmm procedure.