CSPATIALREG Procedure
Example 13.2 Simulated Data Example
Data Description and Objective
This example uses two simulated data sets, SimData and SimW, to illustrate model fitting in PROC CSPATIALREG and to facilitate subsequent discussion.
The SimData data set contains 50 observations and five variables. The variable SID identifies each spatial unit in the data. The 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 13.2.1:
proc means data=mylib.SimData;
var x1 x2 x3 y;
run;
Output 13.2.1: Summary Statistics
| Variable | N | Mean | Std Dev | Minimum | Maximum | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
|
|
|
|
The following statements fit a spatial autoregressive (SAR) model to the data by using three regressors, x1, x2, and x3:
/*-- SAR --*/
proc cspatialreg data=mylib.SimData Wmat=mylib.SimW;
model y=x1-x3 / type=SAR;
spatialid SID;
run;
The parameter estimates for this model are shown in Output 13.2.2.
Output 13.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 a spatial Durbin model (SDM) that includes exogenous interaction effects of x1, x2, and x3, submit the following statements:
/*-- SDM --*/
proc cspatialreg data=mylib.SimData Wmat=mylib.SimW;
model y=x1-x3/ type=SAR;
spatialeffects x1-x3;
spatialid SID;
run;
The parameter estimates for this model are shown in Output 13.2.3.
Output 13.2.3: Parameter Estimates of SDM
| Parameter Estimates | |||||
|---|---|---|---|---|---|
| Parameter | DF | Estimate | Standard Error | t Value | Approx Pr > |t| |
| Intercept | 1 | 1.932578 | 0.198882 | 9.72 | <.0001 |
| x1 | 1 | 0.548504 | 0.049806 | 11.01 | <.0001 |
| x2 | 1 | 0.686011 | 0.056266 | 12.19 | <.0001 |
| x3 | 1 | -0.890161 | 0.053516 | -16.63 | <.0001 |
| W_x1 | 1 | 0.172302 | 0.154018 | 1.12 | 0.2633 |
| W_x2 | 1 | 0.023746 | 0.198557 | 0.12 | 0.9048 |
| W_x3 | 1 | -0.324808 | 0.228032 | -1.42 | 0.1543 |
| _rho | 1 | -0.639757 | 0.164651 | -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 value of the TYPE= option in the MODEL statement. As an example, to fit a spatial error model (SEM) instead of a SAR model to the data, you can use the following statements:
/*-- SEM --*/
proc cspatialreg data=mylib.SimData Wmat=mylib.SimW;
model y=x1-x3 / type=SEM;
spatialid SID;
run;
The parameter estimates for this model are shown in Output 13.2.4.
Output 13.2.4: Parameter Estimates of SEM
| 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 |
The following statements fit a spatial autoregressive confused (SAC) model and spatial autoregressive moving average (SARMA) model to the data:
/*-- SAC --*/
proc cspatialreg data=mylib.SimData Wmat=mylib.SimW;
model y=x1-x3 / type=SAC;
spatialid SID;
run;
/*-- SARMA --*/
proc cspatialreg data=mylib.SimData Wmat=mylib.SimW;
model y=x1-x3 / type=SARMA;
spatialid SID;
run;
The parameter estimates for the SAC and SARMA models are shown in Output 13.2.5 and Output 13.2.6, respectively.
Output 13.2.5: Parameter Estimates of an SAC Model
| Parameter Estimates | |||||
|---|---|---|---|---|---|
| Parameter | DF | Estimate | Standard Error | t Value | Approx Pr > |t| |
| Intercept | 1 | 1.745140 | 0.108969 | 16.01 | <.0001 |
| x1 | 1 | 0.574630 | 0.047481 | 12.10 | <.0001 |
| x2 | 1 | 0.699848 | 0.057547 | 12.16 | <.0001 |
| x3 | 1 | -0.909416 | 0.053365 | -17.04 | <.0001 |
| _rho | 1 | -0.449744 | 0.075425 | -5.96 | <.0001 |
| _lambda | 1 | -0.235971 | 0.277450 | -0.85 | 0.3950 |
| _sigma2 | 1 | 0.128845 | 0.025938 | 4.97 | <.0001 |
Output 13.2.6: Parameter Estimates of a SARMA Model
| Parameter Estimates | |||||
|---|---|---|---|---|---|
| Parameter | DF | Estimate | Standard Error | t Value | Approx Pr > |t| |
| Intercept | 1 | 1.721937 | 0.111720 | 15.41 | <.0001 |
| x1 | 1 | 0.576752 | 0.047432 | 12.16 | <.0001 |
| x2 | 1 | 0.694100 | 0.058118 | 11.94 | <.0001 |
| x3 | 1 | -0.910829 | 0.053061 | -17.17 | <.0001 |
| _rho | 1 | -0.434840 | 0.079844 | -5.45 | <.0001 |
| _lambda | 1 | 0.393432 | 0.342912 | 1.15 | 0.2512 |
| _sigma2 | 1 | 0.133287 | 0.027984 | 4.76 | <.0001 |