SPATIALREG Procedure
Example 31.2 Models with Spatial ID Matching
Data Description and Objective
(View the complete code for this example.)
Two simulated data sets, SIMDATA and SIMW, are used to illustrate models with spatial ID matching in PROC SPATIALREG.
The SIMDATA data set contains 50 observations and five variables. The variable SID identifies each spatial unit in the data. Three explanatory variables are x1, x2, and x3. The dependent variable is y. The SIMW data set defines the spatial contiguity for all 50 spatial units. The first column, SID, in the SIMW data set identifies each spatial unit. The remaining entries in the SIMW data set are binary and define whether two spatial units are neighbors. A value of 1 indicates that two spatial units are neighbors, and 0 indicates otherwise.
Summary statistics for all variables except SID in the SIMDATA data set are computed by the following statements and presented in Output 31.2.1:
proc means data=simdata;
var x1 x2 x3 y;
run;
Output 31.2.1: Summary Statistics
| Variable | N | Mean | Std Dev | Minimum | Maximum | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
|
|
|
|
Because the SIMDATA and SIMW data sets are ordered differently in terms of the values of SID, the SPATIALID statement is needed to match observations in SIMDATA and SIMW. The following statements fit a SAR model to the data by using three regressors, x1, x2, and x3:
proc spatialreg data=simdata Wmat=simw;
model y=x1-x3 / type=SAR;
spatialid SID;
run;
The parameter estimates for this model are shown in Output 31.2.2.
Output 31.2.2: Parameter Estimates of SAR Model
| 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 SDM model that includes exogenous interaction effects of x1, x2, and x3, submit the following statements:
proc spatialreg data=simdata Wmat=simw;
model y=x1-x3/ type=SAR;
spatialeffects x1-x3;
spatialid SID;
run;
The parameter estimates for this model are shown in Output 31.2.3.
Output 31.2.3: Parameter Estimates of SDM Model
| Parameter Estimates | |||||
|---|---|---|---|---|---|
| Parameter | DF | Estimate | Standard Error | t Value | Approx Pr > |t| |
| Intercept | 1 | 1.932575 | 0.198882 | 9.72 | <.0001 |
| x1 | 1 | 0.548505 | 0.049806 | 11.01 | <.0001 |
| x2 | 1 | 0.686012 | 0.056266 | 12.19 | <.0001 |
| x3 | 1 | -0.890162 | 0.053516 | -16.63 | <.0001 |
| W_x1 | 1 | 0.172300 | 0.154018 | 1.12 | 0.2633 |
| W_x2 | 1 | 0.023744 | 0.198557 | 0.12 | 0.9048 |
| W_x3 | 1 | -0.324806 | 0.228032 | -1.42 | 0.1543 |
| _rho | 1 | -0.639755 | 0.164652 | -3.89 | 0.0001 |
| _sigma2 | 1 | 0.120527 | 0.024729 | 4.87 | <.0001 |
If you want to fit another type of model, you need to change the TYPE= option. As an example, if you want 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;
model y=x1-x3 / type=SEM;
spatialid SID;
run;
The parameter estimates for this model are shown in Output 31.2.4.
Output 31.2.4: Parameter Estimates of SEM Model
| 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 |