-------------------------------------------------------------------------------
help: spweight                                                        dialog: s
> pweight
-------------------------------------------------------------------------------

+-------+ ----+ Title +------------------------------------------------------------

spweight: Cross Section and Panel Spatial Weight Matrix

+--------+ ----+ Syntax +-----------------------------------------------------------

spweight varlist (min=2 max=2) , panel(numlist) time(numlist) [ matrix(weight_name) stand inv inv2 eigw(name) tabel ptabel ]

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

spweight creates or generates both Cross Section and Panel Spatial Weight Matrix among neighbor locations, for using in spatial regression analysis.

spweight also creates standardized Weight Matrix with both inverse and inverse squared form and Eigenvalues variable vector.

Raw data for neighbor locations units must be put as shown in the sample data file (spweight.dta).

spweight is differnt from spweightcs and spweightxt, in entering data, you dont have to enter data here in symmetric way (i,j) and (j,i).

+---------+ ----+ Options +----------------------------------------------------------

panel Number of all locations units

time Number of time series in each cross section (must be balanced)

matrix Specify name of spatial weight matrix, that will be created

stand Use row-standardized weight matrix. standardized weight matrix has each row sum equals 1. Default is Binary spatial weight matrix which each element is > 0 or 1

inv Use Inverse Standardized Weight Matrix (1/W)

inv2 Use Inverse Squared Standardized Weight Matrix (1/W^2)

eigw(name) Set name of new eigenvalues variable vector

table Display Cross Section Spatial Weight Matrix Table

ptable Display Panel Spatial Weight Matrix Table

+---------------+ ----+ Saved Results +----------------------------------------------------

spweight saves the following results in e():

Matrixes e(wcs) Cross Section Spatial Weight Matrix. e(wxt) Panel Spatial Weight Matrix.

e(ewcs) Eigenvalues Cross Section. e(ewxt) Eigenvalues Panel Data.

+---------+ ----+ Example +----------------------------------------------------------

clear all sysuse spweight1.dta, clear list v1 v2 spweight v1 v2 , panel(7) matrix(W) eigw table

ereturn list matrix list e(ewcs) matrix list e(wcs)

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

clear all sysuse spweight2.dta, clear list v1 v2 db spweight spweight v1 v2 , panel(4) time(1) matrix(W) eigw table ereturn list matrix list e(ewcs) matrix list e(wcs)

spweight v1 v2 , panel(4) time(2) matrix(W) eigw table spweight v1 v2 , panel(4) time(4) matrix(W) stand eigw table spweight v1 v2 , panel(4) time(4) matrix(W) stand eigw inv table spweight v1 v2 , panel(4) time(4) matrix(W) stand eigw inv2 table spweight v1 v2 , panel(4) time(4) matrix(W) table spweight v1 v2 , panel(4) time(4) matrix(W) ptable spweight v1 v2 , panel(4) time(4) matrix(W) table ptable

. list v1 v2 +---------+ | v1 v2 | |---------| 1. | 1 2 | 2. | 1 3 | 3. | 1 4 | 4. | 2 3 | 5. | 3 4 | +---------+

The final shape of cross section and panel spatial weight matrix will be as follows:

------------------------------------------ Name | c1 c2 c3 c4 Row ------+----------------------------------- r1 | 0 1 1 1 3 r2 | 1 0 1 0 2 r3 | 1 1 0 1 3 r4 | 1 0 1 0 2 ------+----------------------------------- Col | 3 2 3 2 10 ------------------------------------------

(1) (2) (3) (4) |-----------------|-----------------|-----------------|-----------------| (1) | 0 0 0 0 | 1 0 0 0 | 1 0 0 0 | 1 0 0 0 | | 0 0 0 0 | 0 1 0 0 | 0 1 0 0 | 0 1 0 0 | | 0 0 0 0 | 0 0 1 0 | 0 0 1 0 | 0 0 1 0 | | 0 0 0 0 | 0 0 0 1 | 0 0 0 1 | 0 0 0 1 | |-----------------|-----------------|-----------------|-----------------| (2) | 1 0 0 0 | 0 0 0 0 | 1 0 0 0 | 0 0 0 0 | | 0 1 0 0 | 0 0 0 0 | 0 1 0 0 | 0 0 0 0 | | 0 0 1 0 | 0 0 0 0 | 0 0 1 0 | 0 0 0 0 | | 0 0 0 1 | 0 0 0 0 | 0 0 0 1 | 0 0 0 0 | |-----------------|-----------------|-----------------|-----------------| (3) | 1 0 0 0 | 1 0 0 0 | 0 0 0 0 | 1 0 0 0 | | 0 1 0 0 | 0 1 0 0 | 0 0 0 0 | 0 1 0 0 | | 0 0 1 0 | 0 0 1 0 | 0 0 0 0 | 0 0 1 0 | | 0 0 0 1 | 0 0 0 1 | 0 0 0 0 | 0 0 0 1 | |-----------------|-----------------|-----------------|-----------------| (4) | 1 0 0 0 | 0 0 0 0 | 1 0 0 0 | 0 0 0 0 | | 0 1 0 0 | 0 0 0 0 | 0 1 0 0 | 0 0 0 0 | | 0 0 1 0 | 0 0 0 0 | 0 0 1 0 | 0 0 0 0 | | 0 0 0 1 | 0 0 0 0 | 0 0 0 1 | 0 0 0 0 | |-----------------|-----------------|-----------------|------------------

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

if any element has no neighbor with other locations, then you will set its number in both v1 and v2 variables.

for example here element (5) has no neighbor with other locations (1, 2, 3,4), then you will set it self number in both v1 and v2 variables.

clear all sysuse spweight3.dta, clear list v1 v2 spweight v1 v2 , panel(5) matrix(W) eigw table

list v1 v2

+---------+ | v1 v2 | |---------| 1. | 1 2 | 2. | 1 3 | 3. | 1 4 | 4. | 2 3 | 5. | 3 4 | |---------| 6. | 5 5 | +---------+

+---------------------------------------+ | Name | c1 c2 c3 c4 c5 | Row | |-------+-------------------------+-----| | r1 | 0 1 1 1 0 | 3 | | r2 | 1 0 1 0 0 | 2 | | r3 | 1 1 0 1 0 | 3 | | r4 | 1 0 1 0 0 | 2 | | r5 | 0 0 0 0 0 | 0 | |-------+-------------------------+-----| | Col | 3 2 3 2 0 | 10 | +---------------------------------------+ -------------------------------------------------------------------------------

After creating cross section panel spatial weight matrix, you can use spautoreg, gs3sls, spregcs, spmstar for cross section spatial regression, or spregxt, gs2slsxt, spglsxt, spmstarxt, spxttobit for panel spatial regression to generate eigenvalues vector and standardized weight matrix, and run regression analysis.

+--------+ ----+ Author +-----------------------------------------------------------

Emad Abd Elmessih Shehata Assistant Professor Agricultural Research Center - Agricultural Economics Research Institute - Eg > ypt Email: emadstat@hotmail.com WebPage: http://emadstat.110mb.com/stata.htm WebPage at IDEAS: http://ideas.repec.org/f/psh494.html WebPage at EconPapers: http://econpapers.repec.org/RAS/psh494.htm

+-------------------+ ----+ spweight Citation +------------------------------------------------

Shehata, Emad Abd Elmessih (2011) SPWEIGHT: "Stata Module to Create Cross Section and Panel Spatial Weight Matrix" http://ideas.repec.org/c/boc/bocode/s457325.html

http://econpapers.repec.org/software/bocbocode/s457325.htm

Online Help:

gs2slsxt, gs3sls, spautoreg, spcs2xt, spglsxt, spmstar, spmstarxt, spregcs, spregxt, spweight, spweightcs, spweightxt, spxttobit, xtidt. (if installed).