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

The MEANS Procedure

VariableNMeanStd DevMinimumMaximum
x1
x2
x3
y
50
50
50
50
-0.0076329
-0.0829941
-0.0894387
1.1569199
1.0989504
0.9671181
0.9975304
1.5687060
-2.4523193
-2.5725767
-2.4470049
-1.9399423
1.6539456
2.4034547
2.6720533
4.7136835


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

The CSPATIALREG Procedure

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

The CSPATIALREG Procedure

Parameter Estimates
ParameterDFEstimateStandard
Error
t ValueApprox
Pr > |t|
Intercept11.9325780.1988829.72<.0001
x110.5485040.04980611.01<.0001
x210.6860110.05626612.19<.0001
x31-0.8901610.053516-16.63<.0001
W_x110.1723020.1540181.120.2633
W_x210.0237460.1985570.120.9048
W_x31-0.3248080.228032-1.420.1543
_rho1-0.6397570.164651-3.890.0001
_sigma210.1205270.0247294.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

The CSPATIALREG Procedure

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


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

The CSPATIALREG Procedure

Parameter Estimates
ParameterDFEstimateStandard
Error
t ValueApprox
Pr > |t|
Intercept11.7451400.10896916.01<.0001
x110.5746300.04748112.10<.0001
x210.6998480.05754712.16<.0001
x31-0.9094160.053365-17.04<.0001
_rho1-0.4497440.075425-5.96<.0001
_lambda1-0.2359710.277450-0.850.3950
_sigma210.1288450.0259384.97<.0001


Output 13.2.6: Parameter Estimates of a SARMA Model

The CSPATIALREG Procedure

Parameter Estimates
ParameterDFEstimateStandard
Error
t ValueApprox
Pr > |t|
Intercept11.7219370.11172015.41<.0001
x110.5767520.04743212.16<.0001
x210.6941000.05811811.94<.0001
x31-0.9108290.053061-17.17<.0001
_rho1-0.4348400.079844-5.45<.0001
_lambda10.3934320.3429121.150.2512
_sigma210.1332870.0279844.76<.0001


Last updated: July 09, 2026