SPATIALREG Procedure

Example 31.4 Compact Representation of a Spatial Weights Matrix

(View the complete code for this example.)

When a spatial weights matrix is sparse, you might want to provide its compact representation rather than the full matrix to PROC SPATIALREG. In this case, you must use a SPATIALID statement. This example shows you how to use the compact representation of a spatial weights matrix in PROC SPATIALREG. For illustration, the simulated data sets SIMDATA and SIMW in Models with Spatial ID Matching are used here. The compact representation of the spatial weights matrix in the SIMW data set is created and saved in the SIMW_COMPACT data set.

The first 10 observations in the SIMW_COMPACT data set are shown in Output 31.4.1.

Output 31.4.1: SIMW_COMPACT Data Set

ObsSIDcSIDValue
1L50L451
2L30L221
3L42L461
4L32L351
5L7L251
6L33L251
7L50L251
8L23L501
9L9L71
10L45L361


The following statements fit a SAR model:

proc spatialreg data=simdata Wmat=simw_compact;
  model y=x1-x3 / type=SAR;
  spatialid SID;
run;

The parameter estimates for this model are shown in Output 31.4.2.

Output 31.4.2: Parameter Estimates of SAR Model with Compact Representation

The SPATIALREG Procedure
 
Model: MODEL 1
Dependent Variable: y

Parameter Estimates
ParameterDFEstimateStandard
Error
t ValueApprox
Pr > |t|
Intercept11.7806500.09870318.04<.0001
x110.5733290.04739512.10<.0001
x210.7070480.05718112.37<.0001
x31-0.9028430.053314-16.93<.0001
_rho1-0.4737130.063008-7.52<.0001
_sigma210.1315090.0263504.99<.0001


To fit an SEM model instead of a SAR model to the data, you can use the following statements:

proc spatialreg data=simdata Wmat=simw_compact;
  model y=x1-x3 / type=SEM;
  spatialid SID;
run;

The parameter estimates for this model are shown in Output 31.4.3.

Output 31.4.3: Parameter Estimates of SEM Model with Compact Representation

The SPATIALREG Procedure
 
Model: MODEL 1
Dependent Variable: y

Parameter Estimates
ParameterDFEstimateStandard
Error
t ValueApprox
Pr > |t|
Intercept11.1662890.02951439.52<.0001
x110.4879750.0490869.94<.0001
x210.6344420.06177610.27<.0001
x31-0.8312500.054780-15.17<.0001
_lambda1-0.9648260.132514-7.28<.0001
_sigma210.1474340.0313184.71<.0001


Last updated: June 19, 2025