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

Obscrimeincomehvaluelatlonsid
118.80221.23244.56735.6242.38s1
20.1788.43875.00033.3638.41s4
350.73211.25223.22540.0138.00s7
434.00113.59896.40047.6136.42s10
519.14618.94240.30050.1129.91s13
616.24129.83361.95048.4427.93s16
733.70511.70930.45043.3733.46s19
841.9689.91823.60044.1030.40s22
925.96216.96133.50043.2327.31s25
1029.02814.13527.73339.3225.85s28


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

The CSPATIALREG Procedure

Model Fit Summary
Dependent Variablecrime
Number of Observations49
Data SetCRIMEOH
ModelLINEAR
Log Likelihood-187.377
Maximum Absolute Gradient7.599E-7
Number of Iterations16
Optimization MethodNewton-Raphson
AIC382.7542
SBC390.3215
Covariance EstimationHessian


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
ParameterDFEstimateStandard
Error
t ValueApprox
Pr > |t|
Intercept168.6188634.58821014.96<.0001
income1-1.5973040.323739-4.93<.0001
hvalue1-0.2739310.099989-2.740.0062
_sigma21122.75169624.7994934.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

The CSPATIALREG Procedure

Model Fit Summary
Dependent Variablecrime
Number of Observations49
Data SetCRIMEOH
Spatial WeightsCRIMEWMAT
ModelSAR
Spatial ID Variablesid
Log Likelihood-182.36
Maximum Absolute Gradient0.000192
Number of Iterations16
Optimization MethodNewton-Raphson
AIC374.7207
SBC384.1798
Covariance EstimationHessian


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 rho is estimated to be about 0.431, with a p-value of 0.0005.

Figure 5: Parameter Estimates of the SAR Model

Parameter Estimates
ParameterDFEstimateStandard
Error
t ValueApprox
Pr > |t|
Intercept145.0763687.8700025.73<.0001
income1-1.0315140.328375-3.140.0017
hvalue1-0.2659230.088211-3.010.0026
_rho10.4310320.1235863.490.0005
_sigma2195.47031619.4994584.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

The CSPATIALREG Procedure

Model Fit Summary
Dependent Variablecrime
Number of Observations49
Data SetCRIMEOH
Spatial WeightsCRIMEWMAT
ModelSDM
Spatial ID Variablesid
Log Likelihood-181.363
Maximum Absolute Gradient0.000211
Number of Iterations16
Optimization MethodNewton-Raphson
AIC376.7269
SBC389.9696
Covariance EstimationHessian


Figure 7: Parameter Estimates for the SDM

Parameter Estimates
ParameterDFEstimateStandard
Error
t ValueApprox
Pr > |t|
Intercept142.80241013.9238733.070.0021
income1-0.9142000.336418-2.720.0066
hvalue1-0.2937460.088851-3.310.0009
W_income1-0.5196120.594739-0.870.3823
W_hvalue10.2457180.1768431.390.1647
_rho10.4265060.1674852.550.0109
_sigma2191.76826218.9045904.85<.0001


The spatial autoregressive coefficient rho 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 upper H 0 colon rho equals 0 can also be tested against the alternative upper H Subscript a Baseline colon rho not-equals 0 by using the likelihood ratio (LR) test, Lagrange multiplier (LM) test, and Wald test. For the LR test, the test statistic is equal to minus 2 left-parenthesis script upper L Subscript normal l normal i normal n normal e normal a normal r Baseline minus script upper L Subscript normal upper S normal upper A normal upper R Baseline right-parenthesis equals minus 2 left-parenthesis negative 187.38 plus 182.39 right-parenthesis equals 9.98, where script upper L Subscript normal l normal i normal n normal e normal a normal r and script upper L Subscript normal upper S normal upper A normal upper R 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.

Last updated: July 09, 2026