help: spweight dialog:

Title

spweight: Cross Section and Panel Spatial Weight Matrix

Table of Contents

Syntax

Options

Description

Saved Results

*** Examples

Author

Syntax

spweight varlist (min=2 max=2) , panel(numlist) time(numlist)

[ matrix(weight_name) stand inv inv2 eigw(name) tabel ptabel ]

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, if time > 1

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

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.

Examples

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
Professor (PhD Economics)
Agricultural Research Center - Agricultural Economics Research Institute - Egypt
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 (2012)

SPWEIGHT: "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:

*** Spatial Econometrics Regression Models:

--------------------------------------------------------------------------------
*** (1) Spatial Panel Data Regression Models:
spregxt Spatial Panel Regression Econometric Models: Stata Module Toolkit
gs2slsxt Generalized Spatial Panel 2SLS Regression
gs2slsarxt Generalized Spatial Panel Autoregressive 2SLS Regression
spglsxt Spatial Panel Autoregressive Generalized Least Squares Regression
spgmmxt Spatial Panel Autoregressive Generalized Method of Moments Regression
spmstarxt (m-STAR) Spatial Lag Panel Models
spmstardxt (m-STAR) Spatial Durbin Panel Models
spmstardhxt (m-STAR) Spatial Durbin Multiplicative Heteroscedasticity Panel Models
spmstarhxt (m-STAR) Spatial Lag Multiplicative Heteroscedasticity Panel Models
spregdhp Spatial Panel Han-Philips Linear Dynamic Regression: Lag & Durbin Models
spregdpd Spatial Panel Arellano-Bond Linear Dynamic Regression: Lag & Durbin Models
spregfext Spatial Panel Fixed Effects Regression: Lag & Durbin Models
spregrext Spatial Panel Random Effects Regression: Lag & Durbin Models
spregsacxt MLE Spatial AutoCorrelation Panel Regression (SAC)
spregsarxt MLE Spatial Lag Panel Regression (SAR)
spregsdmxt MLE Spatial Durbin Panel Regression (SDM)
spregsemxt MLE Spatial Error Panel Regression (SEM)
--------------------------------------------------------------------------------
*** (2) Spatial Cross Section Regression Models:
spregcs Spatial Cross Section Regression Econometric Models: Stata Module Toolkit
gs2sls Generalized Spatial 2SLS Cross Sections Regression
gs2slsar Generalized Spatial Autoregressive 2SLS Cross Sections Regression
gs3sls Generalized Spatial Autoregressive 3SLS Regression
gs3slsar Generalized Spatial Autoregressive 3SLS Cross Sections Regression
gsp3sls Generalized Spatial 3SLS Cross Sections Regression
spautoreg Spatial Cross Section Regression Models
spgmm Spatial Autoregressive GMM Cross Sections Regression
spmstar (m-STAR) Spatial Lag Cross Sections Models
spmstard (m-STAR) Spatial Durbin Cross Sections Models
spmstardh (m-STAR) Spatial Durbin Multiplicative Heteroscedasticity Cross Sections Models
spmstarh (m-STAR) Spatial Lag Multiplicative Heteroscedasticity Cross Sections Models
spregsac MLE Spatial AutoCorrelation Cross Sections Regression (SAC)
spregsar MLE Spatial Lag Cross Sections Regression (SAR)
spregsdm MLE Spatial Durbin Cross Sections Regression (SDM)
spregsem MLE Spatial Error Cross Sections Regression (SEM)
--------------------------------------------------------------------------------
*** (3) Tobit Spatial Regression Models:

*** (3-1) Tobit Spatial Panel Data Regression Models:
sptobitgmmxt Tobit Spatial GMM Panel Regression
sptobitmstarxt Tobit (m-STAR) Spatial Lag Panel Models
sptobitmstardxt Tobit (m-STAR) Spatial Durbin Panel Models
sptobitmstardhxt Tobit (m-STAR) Spatial Durbin Multiplicative Heteroscedasticity Panel Models
sptobitmstarhxt Tobit (m-STAR) Spatial Lag Multiplicative Heteroscedasticity Panel Models
sptobitsacxt Tobit MLE Spatial AutoCorrelation (SAC) Panel Regression
sptobitsarxt Tobit MLE Spatial Lag Panel Regression
sptobitsdmxt Tobit MLE Spatial Panel Durbin Regression
sptobitsemxt Tobit MLE Spatial Error Panel Regression
spxttobit Tobit Spatial Panel Autoregressive GLS Regression
--------------------------------------------------------------
*** (3-2) Tobit Spatial Cross Section Regression Models:
sptobitgmm Tobit Spatial GMM Cross Sections Regression
sptobitmstar Tobit (m-STAR) Spatial Lag Cross Sections Models
sptobitmstard Tobit (m-STAR) Spatial Durbin Cross Sections Models
sptobitmstardh Tobit (m-STAR) Spatial Durbin Multiplicative Heteroscedasticity Cross Sections
sptobitmstarh Tobit (m-STAR) Spatial Lag Multiplicative Heteroscedasticity Cross Sections
sptobitsac Tobit MLE AutoCorrelation (SAC) Cross Sections Regression
sptobitsar Tobit MLE Spatial Lag Cross Sections Regression
sptobitsdm Tobit MLE Spatial Durbin Cross Sections Regression
sptobitsem Tobit MLE Spatial Error Cross Sections Regression
--------------------------------------------------------------------------------
*** (4) Spatial Weight Matrix:
spcs2xt Convert Cross Section to Panel Spatial Weight Matrix
spweight Cross Section and Panel Spatial Weight Matrix
spweightcs Cross Section Spatial Weight Matrix
spweightxt Panel Spatial Weight Matrix
--------------------------------------------------------------------------------