Title
spwmatfill --- Assigns first nearest neighbors to observations with no contiguous neighbors.
+--------------------+ ----+ Table of Contents +-----------------------------------------------
Syntax General description Description of the options Examples Citation Author information -------------------------------------------------------------------------------
spwmatfill varlist, id(varname) inwname(inwght_name) inwfrom(Mata|Stata) outwname(wght_name) [Other_options]
options Description ------------------------------------------------------------------------- Options id(varname) indicate the name of the identifier variable.
inwname(inwght_name) indicate the name of the input spatial weights matrix; i.e, the contiguity spatial weights.
inwfrom(Stata|Mata) indicate the source of the input spatial weights matrix.
outwname(outwght_name) indicate a name for the output spatial weights matrix.
cart use Cartesian coordinates (projected latitudes and longitudes).
r(#) indicate the earth radius value to use in case of spherical coordinates, default is 6371.009 km.
mataf save the output spatial weights matrix and its eigenvalues to Mata files.
eignval(eign_name) specify a name for a column vector or a file to hold the eigen values.
eignvar(newvar) specify a variable name to hold the eigen values.
rowstand row-standardize the spatial weights matrix.
matlab(dat_filename) export the weights matrix as a .dat (text) file for use in Matlab.
replace overwrite dat_filename if it already exists as well as wght_name and eig_name if mataf is specified and these two matri > ces already exit as Mata files.
connect display connectivity information about the spatial weights
-------------------------------------------------------------------------
+-------------+ ----+ Description +------------------------------------------------------
spwmatfill takes a contiguity-based spatial weights matrix -created in GeoDa- whose some rows consisting of only zero elements represent observations with no contiguous neighbors, assigns to those observations their nearest neighbors as their sole neighbors, and replaces the zero elements corresponding to the nearest neighbors with ones. In order to calculate the first nearest neighbors spwmatfill relies on nearestat which must be installed.
+------------------+ ----+ Required Options +-------------------------------------------------
id(varname) specifies the name of the identifier variable. It is paramount that the sort order of this variable values be the same as that of the values of the key variable used to generate the spatial weights in GeoDa.
inwname(inwght_name) specifies the name of the input spatial weights matrix to be used. This spatial weights matrix, which should not be row-standardized, must have been imported from GeoDa using spwmatrix
inwfrom(Stata | Mata) indicates whether the input spatial weights exist as Stata matrix loaded in memory or as a Mata file.
outwname(outwght_name) provides a name for the output spatial weights matrix.
+------------------+ ----+ Optional Options +-------------------------------------------------
cart indicates that the latitudes and longitudes supplied in varlist are projected. By default, sperical coordinates (latitudes and longitudes in decimal degrees) are assumed.
r(#) indicates the value for the Earth radius or mean radius to be used in case of spherical coordinates. The default is r(6371.009).
Options r(#) and cart may not be combined. For more on these options, see the help file for nearstat.
mataf requests that the output spatial weights matrix and its eigenvalues be saved to permanent Mata files. For more details, see the mataf option of the spwmatrix command.
eignval(eign_name) specifies that eigenvalues of the output spatial weights be written to the N x 1 vector or file eign_name.
eignvar(newvar) specifies a variable name to hold the eigenvalues.
rowstand requests that the output spatial weights be row-standardized.
matlab(dat_filename) specifies that the output spatial weights be written to the text file dat_filename.dat for use in Matlab.
replace overwrites newvar and dat_filename as well as outwght_name and eign_name if mataf is specified.
connect requests that connectivity information such as sparseness, average number of neighbors, etc... for the output spatial weights be displayed.
+---------+ ----+ Example +----------------------------------------------------------
First import a first order contiguity spatial weights matrix created in GeoDa and save it to a Mata file. Note that it is important not to row-standardize the weights matrix at this time.
. spwmatrix using C:\data\wcontig.gal, wname(wcontig) mataf
You now are ready to run spwmatfill
. spwmatfill latitude longitude, id(obsid_n) inwname(wcontig) inwfrom(Mata) outwname(wcontigfil) rowstand /// cart mataf eignvar(eigncontig) matlab(wcontigfil)
-----------------------------------------------------------------------------
Users should please cite as: Jeanty, P. Wilner. 2010. spwmatfill: Stata module to assign first nearest neigh > bors to observations with no contiguous neighbors.
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.
Also see
Online: nearstat and spwmatrix (if installed)