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
| Obs | SID | cSID | Value |
|---|---|---|---|
| 1 | L50 | L45 | 1 |
| 2 | L30 | L22 | 1 |
| 3 | L42 | L46 | 1 |
| 4 | L32 | L35 | 1 |
| 5 | L7 | L25 | 1 |
| 6 | L33 | L25 | 1 |
| 7 | L50 | L25 | 1 |
| 8 | L23 | L50 | 1 |
| 9 | L9 | L7 | 1 |
| 10 | L45 | L36 | 1 |
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
| Parameter Estimates | |||||
|---|---|---|---|---|---|
| Parameter | DF | Estimate | Standard Error | t Value | Approx Pr > |t| |
| Intercept | 1 | 1.780650 | 0.098703 | 18.04 | <.0001 |
| x1 | 1 | 0.573329 | 0.047395 | 12.10 | <.0001 |
| x2 | 1 | 0.707048 | 0.057181 | 12.37 | <.0001 |
| x3 | 1 | -0.902843 | 0.053314 | -16.93 | <.0001 |
| _rho | 1 | -0.473713 | 0.063008 | -7.52 | <.0001 |
| _sigma2 | 1 | 0.131509 | 0.026350 | 4.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
| Parameter Estimates | |||||
|---|---|---|---|---|---|
| Parameter | DF | Estimate | Standard Error | t Value | Approx Pr > |t| |
| Intercept | 1 | 1.166289 | 0.029514 | 39.52 | <.0001 |
| x1 | 1 | 0.487975 | 0.049086 | 9.94 | <.0001 |
| x2 | 1 | 0.634442 | 0.061776 | 10.27 | <.0001 |
| x3 | 1 | -0.831250 | 0.054780 | -15.17 | <.0001 |
| _lambda | 1 | -0.964826 | 0.132514 | -7.28 | <.0001 |
| _sigma2 | 1 | 0.147434 | 0.031318 | 4.71 | <.0001 |