*! version 1.0.2 26nov2018
help spmat dta

Title

spmat dta -- Create an spmat object from a
rectangular Stata dataset

Syntax

spmat dta objname varlist [if] [in] [, options]

id(varname) variable containing unique IDs

rcv data are in a (row, column, value) format

idistance convert distance data to inverse distances

normalize(norm) normalization method

replace replace objname

Description

spmat dta creates the spmat object objname from a Stata dataset.

If the dataset contains the entries of an n x n spatial-weighting matrix,
then the number of variables in varlist should be equal to the number of
observations in the dataset.

If the dataset represents the spatial-weighting matrix in a (row, column, value)
format, also known as a coordinate list, then varlist must specify three
variables.

Options

id(varname) specifies a variable containing unique place
identifiers. If this option is omitted, spmat dta will
create the IDs 1, ..., n.

rcv tells spmat that the data are in a (row, column, value) format.

idistance tells spmat that the data are to be converted to inverse
distances. The value d will be converted to 1/d with the exception
of the main diagonal, which will contain zero entries.

normalize(norm) specifies the normalization method.
norm can be row, minmax, or spectral.

replace allows objname to be overwritten if it already exists.

Example

Setup

. spmat use cobj using pollute.spmat

. spmat export cobj using cobj.txt

. spmat drop cobj

. insheet using cobj.txt, delimiter(" ") clear

. rename v1 id

Create the spmat object cobj containing a contiguity matrix
stored in the variables v2-v542

. spmat dta cobj v*, id(id) replace

Setup

. clear

. set obs 4

. gen id1 = _n

. gen id2 = _n+1

. gen val = _n

Create the spmat object dobj containing a distance matrix
where variable val measures the distance between id1 and id2

. spmat dta dobj id1 id2 val, rcv

Also see

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