help spmat idistance


spmat idistance -- Create an spmat object containing an inverse-distance spatial-weighting matrix W


spmat idistance objname varlist [if] [in], id(varname) [options]

options Description ------------------------------------------------------------------------- * id(varname) ID variable dfunction(function[, miles]) distance function normalize(norm) normalization method btruncate(b B) bin truncation dtruncate(l u) diagonal truncation vtruncate(#) value truncation banded banded storage replace replace objname ------------------------------------------------------------------------- * Required Only one of btruncate(), dtruncate(), or vtruncate() may be specified.


spmat idistance puts an inverse-distance spatial-weighting matrix W into the new spmat object objname. The ijth element of W contains the inverse of the distance between points i and j calculated from the coordinate variables specified in varlist. Longitude must be specified first if coordinate variables represent longitude and latitude.


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

dfunction(function[, miles]) specifies the distance function. function may be one of euclidean (default), dhaversine, rhaversine, or the Minkowski distance of order p where p is an integer greater than or equal to 1.

Use dhaversine when your coordinate variables are in degrees; use rhaversine when your coordinate variables are in radians. By default, the distances are calculated in kilometers; specify the optional miles argument if you want the distances to be calculated in miles.

normalize(norm) specifies the normalization method. norm may be one of row, minmax, or spectral.

truncate() options specify one of the three available truncation criteria. The values of the spatial-weighting matrix W that meet the truncation criterion will be changed to zero.

btruncate(b B) partitions the value of W into B bins and truncates to zero entries that fall into bin b or below.

dtruncate(l u) truncates to zero the values of W that fall l diagonals below and u diagonals above the main diagonal. Neither value can be greater than floor((cols(W)-1)/4).

vtruncate(#) truncates to zero the values of W that are less than or equal to #.

banded instructs spmat to store the truncated inverse-distance matrix in a banded form; see Remarks in spmat tobanded for details.

replace allows objname to be overwritten if it already exists.


Setup . use pollute

Create the spmat object dobj containing an inverse-distance matrix . spmat idistance dobj longitude latitude, id(id) dfunction(dhaversine)

Also see

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