CSPATIALREG Procedure
Getting Started: CSPATIALREG Procedure
Note: Input data must be in a CAS table that is accessible in your CAS session. You must refer to this table by using a two-level name. The first level must be a CAS engine libref, and the second level must be the table name. For more information, see the sections Using CAS Sessions and CAS Engine Librefs and Loading a SAS Data Set onto a CAS Server in Chapter 4, Shared Concepts.
The CSPATIALREG procedure is similar to other SAS regression model procedures for nonspatial data, except that in PROC CSPATIALREG you usually need to provide a secondary data table (in the WMAT= option), which provides information about spatial weights matrix. The spatial weights matrix defines all pairwise spatial relationships and is a vital component of a spatial econometric model. For more information about how to create spatial weights matrix, see the section Specifying the Spatial Weights Matrix.
The following statements fit a SAR model:
proc cspatialreg data=mylib.One Wmat=mylib.W;
model y = x1 x2 / type=SAR;
spatialid sid;
run;
The response variable y (a continuous variable) and the explanatory variables x1 and x2 are contained in the data table mylib.One. The spatial weights matrix that you specify using the WMAT= option defines neighbor relationships among all spatial units in the data. The SPATIALID statement specifies a spatial ID variable that identifies spatial units in two data tables that you provide in the DATA= and WMAT= options. You specify the TYPE=SAR option in the MODEL statement to request a SAR model.
The following example illustrates PROC CSPATIALREG by using a real-world data set. The data set CrimeOH is taken from Anselin (1988). This data set contains variables such as Income (household income, measured in $1,000), HValue (housing value by $1,000), and Crime (number of crimes, including residential burglaries and vehicle thefts, measured per 1,000 households) in 49 neighborhoods in Columbus, Ohio. You want to examine how household income and housing value affect the number of crimes in these neighborhoods.
The first 10 observations in the mylib.CrimeOH data set are shown in Figure 1.
Figure 1: Columbus Crime Data
| Obs | crime | income | hvalue | lat | lon | sid |
|---|---|---|---|---|---|---|
| 1 | 18.802 | 21.232 | 44.567 | 35.62 | 42.38 | s1 |
| 2 | 0.178 | 8.438 | 75.000 | 33.36 | 38.41 | s4 |
| 3 | 50.732 | 11.252 | 23.225 | 40.01 | 38.00 | s7 |
| 4 | 34.001 | 13.598 | 96.400 | 47.61 | 36.42 | s10 |
| 5 | 19.146 | 18.942 | 40.300 | 50.11 | 29.91 | s13 |
| 6 | 16.241 | 29.833 | 61.950 | 48.44 | 27.93 | s16 |
| 7 | 33.705 | 11.709 | 30.450 | 43.37 | 33.46 | s19 |
| 8 | 41.968 | 9.918 | 23.600 | 44.10 | 30.40 | s22 |
| 9 | 25.962 | 16.961 | 33.500 | 43.23 | 27.31 | s25 |
| 10 | 29.028 | 14.135 | 27.733 | 39.32 | 25.85 | s28 |
The following SAS statements fit a linear regression model to the CrimeOH data set:
/*-- Linear Model --*/
proc cspatialreg data=mylib.CrimeOH;
model crime = income hvalue / type=LINEAR;
run;
The "Model Fit Summary" table, shown in Figure 2, lists several fit summary statistics for the model. By default, the CSPATIALREG procedure uses the Newton-Raphson optimization technique. The maximum log-likelihood value is shown, in addition to two information measures, Akaike’s information criterion (AIC) and Schwarz’s Bayesian information criterion (SBC). AIC or SBC can be used for model selection. For a set of candidate models, the model that has the smallest AIC or SBC is often preferred. In addition, the method that is used for covariance estimation is shown.
Figure 2: Fit Summary Statistics for a Linear Model
| Model Fit Summary | |
|---|---|
| Dependent Variable | crime |
| Number of Observations | 49 |
| Data Set | CRIMEOH |
| Model | LINEAR |
| Log Likelihood | -187.377 |
| Maximum Absolute Gradient | 7.599E-7 |
| Number of Iterations | 16 |
| Optimization Method | Newton-Raphson |
| AIC | 382.7542 |
| SBC | 390.3215 |
| Covariance Estimation | Hessian |
The parameter estimates of the model and their standard errors are shown in Figure 3. Based on the p-values, both Income and HValue are significant at the 0.05 level.
Figure 3: Parameter Estimates of the Linear Model
| Parameter Estimates | |||||
|---|---|---|---|---|---|
| Parameter | DF | Estimate | Standard Error | t Value | Approx Pr > |t| |
| Intercept | 1 | 68.618863 | 4.588210 | 14.96 | <.0001 |
| income | 1 | -1.597304 | 0.323739 | -4.93 | <.0001 |
| hvalue | 1 | -0.273931 | 0.099989 | -2.74 | 0.0062 |
| _sigma2 | 1 | 122.751696 | 24.799493 | 4.95 | <.0001 |
The following statements fit a SAR model to the CrimeOH data set:
/*-- SAR Model --*/
proc cspatialreg data=mylib.CrimeOH Wmat=mylib.CrimeWmat NONORMALIZE;
model crime = income hvalue / type=SAR;
spatialid sid;
run;
The NONORMALIZE option requests that the spatial weights matrix that is specified in the mylib.CrimeWmat data table be used "as is" rather than be row-standardized. The "Model Fit Summary" table, shown in Figure 4, lists several fit summary statistics for the SAR model. For this model, the value of AIC is about 374.78—smaller than 382.75, which is the AIC value for the preceding linear model. Based on AIC, the SAR model is preferred.
Figure 4: Fit Summary Statistics for the SAR Model
| Model Fit Summary | |
|---|---|
| Dependent Variable | crime |
| Number of Observations | 49 |
| Data Set | CRIMEOH |
| Spatial Weights | CRIMEWMAT |
| Model | SAR |
| Spatial ID Variable | sid |
| Log Likelihood | -182.36 |
| Maximum Absolute Gradient | 0.000192 |
| Number of Iterations | 16 |
| Optimization Method | Newton-Raphson |
| AIC | 374.7207 |
| SBC | 384.1798 |
| Covariance Estimation | Hessian |
The parameter estimates of the SAR model and their standard errors are shown in Figure 5. According to the p-values, both Income and HValue are significant at the 0.05 level. In addition, the spatial autoregressive coefficient is estimated to be about 0.431, with a p-value of 0.0005.
Figure 5: Parameter Estimates of the SAR Model
| Parameter Estimates | |||||
|---|---|---|---|---|---|
| Parameter | DF | Estimate | Standard Error | t Value | Approx Pr > |t| |
| Intercept | 1 | 45.076368 | 7.870002 | 5.73 | <.0001 |
| income | 1 | -1.031514 | 0.328375 | -3.14 | 0.0017 |
| hvalue | 1 | -0.265923 | 0.088211 | -3.01 | 0.0026 |
| _rho | 1 | 0.431032 | 0.123586 | 3.49 | 0.0005 |
| _sigma2 | 1 | 95.470316 | 19.499458 | 4.90 | <.0001 |
Unlike the previous SAR model, a spatial Durbin model (SDM) accounts for exogenous interaction effects by introducing additional spatially lagged regressors into the model. To fit an SDM, you need to combine the MODEL statement (with the TYPE=SAR option) and the SPATIALEFFECTS statement. The following statements fit an SDM :
/*-- SDM --*/
proc cspatialreg data=mylib.CrimeOH Wmat=mylib.CrimeWmat NONORMALIZE;
model crime = income hvalue / type=SAR;
spatialeffects income hvalue;
spatialid sid;
run;
The fit summary statistics for the SDM are shown in Figure 6. Parameter estimates are provided in Figure 7.
Figure 6: Fit Summary Statistics for the SDM
| Model Fit Summary | |
|---|---|
| Dependent Variable | crime |
| Number of Observations | 49 |
| Data Set | CRIMEOH |
| Spatial Weights | CRIMEWMAT |
| Model | SDM |
| Spatial ID Variable | sid |
| Log Likelihood | -181.363 |
| Maximum Absolute Gradient | 0.000211 |
| Number of Iterations | 16 |
| Optimization Method | Newton-Raphson |
| AIC | 376.7269 |
| SBC | 389.9696 |
| Covariance Estimation | Hessian |
Figure 7: Parameter Estimates for the SDM
| Parameter Estimates | |||||
|---|---|---|---|---|---|
| Parameter | DF | Estimate | Standard Error | t Value | Approx Pr > |t| |
| Intercept | 1 | 42.802410 | 13.923873 | 3.07 | 0.0021 |
| income | 1 | -0.914200 | 0.336418 | -2.72 | 0.0066 |
| hvalue | 1 | -0.293746 | 0.088851 | -3.31 | 0.0009 |
| W_income | 1 | -0.519612 | 0.594739 | -0.87 | 0.3823 |
| W_hvalue | 1 | 0.245718 | 0.176843 | 1.39 | 0.1647 |
| _rho | 1 | 0.426506 | 0.167485 | 2.55 | 0.0109 |
| _sigma2 | 1 | 91.768262 | 18.904590 | 4.85 | <.0001 |
The spatial autoregressive coefficient is estimated to be 0.426 with a p-value of 0.0109 based on an asymptotic t test. This result seems to suggest that there is a significantly positive spatial dependence in the number of crimes.
In the CSPATIALREG procedure, the null hypothesis can also be tested against the alternative
by using the likelihood ratio (LR) test, Lagrange multiplier (LM) test, and Wald test. For the LR test, the test statistic is equal to
, where
and
are the log likelihoods for the linear regression model and SAR model, respectively. The likelihood ratio test is significant at the 0.05 level, providing strong evidence of spatial dependence in the data.