help spmat contiguity-------------------------------------------------------------------------------

Title

spmat contiguity-- Create anspmatobject containing a contiguity matrixW

Syntax

spmatcontiguityobjname[if] [in]usingfilename,id(varname)[options]

optionsDescription ------------------------------------------------------------------------- *id(varname)ID variablerookrook contiguitynormalize(norm)normalization methodtolerance(#)numerical tolerancebandedbanded storagereplacereplaceobjnamesaving(filename,...)save neighbor info to a text filenomatrixdo not createobjname------------------------------------------------------------------------- * Required

Description

spmat contiguityputs a contiguity matrixWinto the newspmatobjectobjname. Theijth element ofWis 1 if pointsiandjare neighbors and is 0 otherwise.

spmat contiguityuses both the dataset in memory and a dataset containing the coordinates of polygons. The coordinates dataset must be in the format created by shp2dta or mif2dta.

Options

id(varname)specifies a numeric variable that contains a unique identifier for each observation. This option is required.

rookspecifies that only points that share a common edge should be considered neighbors (rook contiguity). The default is to include points that share a common vertex (queen contiguity). Rook contiguity is computationally more difficult than queen contiguity.

normalize(norm)specifies the normalization method.normcan berow,minmax, orspectral.

tolerance(#)specifies the numerical tolerance used in deciding whether two places are rook neighbors. The default istolerance(1e-7).

bandedinstructsspmatto store the contiguity matrix in a banded form; seeRemarksinspmat tobandedfor details.

replaceallowsobjnameto be overwritten if it already exists.

saving(filename[, replace])requests that the matrix be written tofilenamein the neighbor-list format. The first line of the file contains the total number of places and, if the matrix is banded, the lower and upper band. Each remaining line lists a place ID followed by its neighbors, if any.replaceallowsfilenameto be overwritten if it already exists.

nomatrixspecifies that thespmatobjectobjnameand spatial-weighting matrixWnot be created. In conjunction withsaving(), this option allows for creating a text file containing a neighbor list without constructing the underlying contiguity matrix.

ExampleSetup

. clear all. set memory 50m. use polluteCreate the spmat object

cobjcontaining a minmax-normalized contiguity matrix. spmat contiguity cobj using pollutexy, id(id) normalize(minmax)

Also seeOnline:

spmat,spreg,spivreg,spmap,shp2dta,mif2dta(if installed)