-------------------------------------------------------------------------------help for spwmatfill-------------------------------------------------------------------------------

Title

spwmatfill --- Assigns first nearest neighbors to observations with nocontiguous neighbors.+--------------------+ ----+ Table of Contents +-----------------------------------------------

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

spwmatfillvarlist,id(varname)inwname(inwght_name)inwfrom(Mata|Stata)outwname(wght_name)[Other_options]

optionsDescription ------------------------------------------------------------------------- Optionsid(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.

cartuse Cartesian coordinates (projected latitudes and longitudes).

r(#)indicate the earth radius value to use in case of spherical coordinates, default is 6371.009 km.

matafsave 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.

rowstandrow-standardize the spatial weights matrix.

matlab(dat_filename)export the weights matrix as a .dat (text) file for use inMatlab.

replaceoverwritedat_filenameif it already exists as well aswght_nameandeig_nameifmatafis specified and these two matri > ces already exit as Mata files.

connectdisplay connectivity information about the spatial weights

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

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

spwmatfilltakes 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 neighborsspwmatfillrelies 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 shouldnotbe 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 +-------------------------------------------------

cartindicates that the latitudes and longitudes supplied invarlistare 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 isr(6371.009).Options

r(#)andcartmay not be combined. For more on these options, see the help file for nearstat.

matafrequests that the output spatial weights matrix and its eigenvalues be saved to permanent Mata files. For more details, see the mataf option of thespwmatrixcommand.

eignval(eign_name)specifies that eigenvalues of the output spatial weights be written to theN x 1vector or fileeign_name.

eignvar(newvar)specifies a variable name to hold the eigenvalues.

rowstandrequests that the output spatial weights be row-standardized.

matlab(dat_filename)specifies that the output spatial weights be written to the text filedat_filename.datfor use in Matlab.

replaceoverwritesnewvaranddat_filenameas well asoutwght_nameandeign_nameifmatafis specified.

connectrequests 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) matafYou 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 UniversityEmail to jeanty.1@osu.edu for any comments or suggestions.

Also seeOnline:

nearstatandspwmatrix(if installed)