COUNTREG Procedure

Example 11.4 Spatial Effects

(View the complete code for this example.)

This example demonstrates how to use the COUNTREG procedure to model count data with spatial effects. The data set Shigdata contains county-level data related to shigellosis, an infectious bacterial disease. The dependent variable Shigellosis records the number of shigellosis cases reported in each California county in 2011. The data are from the California Department of Public Health. Additional variables include PopDensity (population in thousands per square mile), Hispanic (percentage of Hispanic population), and BigHousehold (percentage of households with six or more persons); these data are from the 2010 United States Census. The following statements compute summary statistics for these variables and the frequency of each observed shigellosis count:

proc means data=Shigdata;
   var Shigellosis PopDensity Hispanic BigHousehold;
run;
proc freq data=Shigdata;
   table Shigellosis;
run;

The results are presented in Output 11.4.1.

Output 11.4.1: Summary Statistics and Frequency of Counts

The MEANS Procedure

VariableNMeanStd DevMinimumMaximum
Shigellosis
PopDensity
Hispanic
Bighousehold
58
58
58
58
16.3620690
0.6632695
28.4724138
6.3818966
40.6692687
2.3148907
17.3124947
3.4006318
0
0.0015900
6.9600000
1.7500000
284.0000000
17.1801800
80.3700000
13.1500000

The FREQ Procedure

ShigellosisFrequency PercentCumulative
Frequency
Cumulative
Percent
01831.031831.03
158.622339.66
211.722441.38
346.902848.28
458.623356.90
511.723458.62
611.723560.34
823.453763.79
923.453967.24
1211.724068.97
1311.724170.69
1511.724272.41
1623.454475.86
1711.724577.59
1811.724679.31
2123.454882.76
2511.724984.48
2611.725086.21
3411.725187.93
3711.725289.66
3911.725391.38
4811.725493.10
5011.725594.83
6411.725696.55
10911.725798.28
28411.7258100.00


The number of observations is 58, which is the number of California counties. The variance of Shigellosis (1653.99) is much larger than its mean (16.36), suggesting overdispersion. Moreover, the fact that 18 counties (31.03%) have counts of 0 indicates zero-inflation in the data.

A map of California counties that shows their shigellosis counts would help visualize any spatial effects. You can generate such a map by using the following statements:

ods graphics on;
goptions reset=all border;
data ca;
   set maps.counties;
   where state = 6;
run;

proc sort data=ca out=ca;
   by county;
run;

pattern value=mempty color=blue;

/* The COUNTY and COUNTIES data sets are unprojected */
/* Without the gproject procedure, you would get an inverse map */
proc gproject data=ca out=caproj;
   id state county;
run;

proc gmap map=caproj data=Shigdata all;
   id county;
   choro Shigellosis/discrete coutline=black;
run;

The map is shown in Output 11.4.2.

Output 11.4.2: California Map Showing Shigellosis Counts

California Map Showing Shigellosis Counts


The following statements fit a Poisson model with spatially weighted regressors:

proc countreg data=Shigdata Wmat=W;
   model Shigellosis = PopDensity BigHousehold / dist=poisson;
   spatialeffects PopDensity BigHousehold;
run;

The SPATIALEFFECTS statement accounts for spatial effects on regressors in the MODEL statement. Because there might be local spillovers in the two explanatory variables, PopDensity and BigHousehold, both variables are included in the SPATIALEFFECTS statement. The data set W contains the spatial weights matrix. The model fit summary, convergence status, and parameter estimation results are shown in Output 11.4.3.

Output 11.4.3: Poisson Model with Spatially Weighted Regressors

The COUNTREG Procedure

Model Fit Summary
Dependent VariableShigellosis
Number of Observations58
Data SetWORK.SHIGDATA
ModelPoisson
Log Likelihood-450.76547
Maximum Absolute Gradient3.81352E-8
Number of Iterations5
Optimization MethodNewton-Raphson
AIC911.53094
SBC921.83315

Algorithm converged.

Parameter Estimates
ParameterDFEstimateStandard
Error
t ValueApprox
Pr > |t|
Intercept1-3.8013130.291041-13.06<.0001
PopDensity10.2573880.00875229.41<.0001
Bighousehold10.1476680.0149029.91<.0001
W_PopDensity10.5667560.03200517.71<.0001
W_Bighousehold10.5674330.02660621.33<.0001


As shown in the "Parameter Estimates" table, all estimates are significant at the 5% level. The spatially weighted regressors are labeled with the prefix "W_". Because of the likely overdispersion in the data, you might consider using a negative binomial model. The following statements fit a negative binomial model with spatially weighted regressors:

proc countreg data=Shigdata Wmat=W;
   model Shigellosis = PopDensity BigHousehold / dist=negbin;
   spatialeffects PopDensity BigHousehold;
run;

The model fit summary, convergence status, and parameter estimation results are listed in Output 11.4.4.

Output 11.4.4: Negative Binomial Model with Spatially Weighted Regressors

The COUNTREG Procedure

Model Fit Summary
Dependent VariableShigellosis
Number of Observations58
Data SetWORK.SHIGDATA
ModelNegBin(p=2)
Log Likelihood-165.09815
Maximum Absolute Gradient3.89549E-8
Number of Iterations6
Optimization MethodNewton-Raphson
AIC342.19629
SBC354.55895

Algorithm converged.

Parameter Estimates
ParameterDFEstimateStandard
Error
t ValueApprox
Pr > |t|
Intercept1-2.2961880.541472-4.24<.0001
PopDensity10.2934220.1039912.820.0048
Bighousehold10.2002430.0635053.150.0016
W_PopDensity10.5425990.1781253.050.0023
W_Bighousehold10.3299660.0892323.700.0002
_Alpha11.0296080.2594753.97<.0001


The AIC and SBC values in the "Model Fit Summary" table in Output 11.4.4 are both smaller than those in Output 11.4.3, indicating that the negative binomial model provides a better fit than the Poisson model. The parameter estimate for _Alpha is an estimate of the dispersion parameter in the negative binomial distribution. The null hypothesis that _Alpha is 0 can be tested against the alternative hypothesis that _Alpha is positive, by using the likelihood ratio test. The likelihood ratio test statistic is minus 2 left-parenthesis script upper L Subscript upper P Baseline minus script upper L Subscript upper N upper B Baseline right-parenthesis equals minus 2 left-parenthesis negative 450.77 plus 165.10 right-parenthesis equals 571.34, where script upper L Subscript upper P and script upper L Subscript upper N upper B are the log likelihoods for the Poisson (null) and negative binomial (alternative) models, respectively. The likelihood ratio test is highly significant at the 5% level, providing strong evidence of overdispersion.

An alternative model to account for overdispersion is the Conway-Maxwell-Poisson (CMP) model, which uses dispersion regressors to model the parameter nu that controls the degree of dispersion. The following statements fit a CMP model that accounts for local spillovers in both model regressors and includes a DISPMODEL statement for the dispersion model:

proc countreg data=Shigdata Wmat=W;
   model Shigellosis =  PopDensity / dist=compoisson;
   spatialeffects PopDensity;
   dispmodel Shigellosis ~ Hispanic;
   spatialdispeffects Hispanic;
run;

The model fit summary, convergence status, and parameter estimation results are provided in Output 11.4.5.

Output 11.4.5: CMP Model with Spatially Weighted Regressors

The COUNTREG Procedure

Model Fit Summary
Dependent VariableShigellosis
Number of Observations58
Data SetWORK.SHIGDATA
ModelCMPoisson
ParameterizationMu
Log Likelihood-175.88177
Maximum Absolute Gradient6.7876E-10
Number of Iterations21
Optimization MethodNewton-Raphson
AIC363.76354
SBC376.12620

Algorithm converged.

Parameter Estimates
ParameterDFEstimateStandard
Error
t ValueApprox
Pr > |t|
Intercept1-16.68782426.882100-0.620.5347
PopDensity10.9658271.1923380.810.4179
W_PopDensity13.3094344.3528530.760.4471
Dsp_Intercept11.7151791.7172221.000.3179
Dsp_Hispanic10.0369190.0151752.430.0150
Dsp_W_Hispanic10.0687710.0188943.640.0003


The regression coefficients in the DISPMODEL statement are labeled with the prefix "Dsp_", and their spatially weighted counterparts in the DISPSPATIALEFFECTS statement are labeled with the prefix "Dsp_W". Both coefficients—Dsp_Hispanic and Dsp_W_Hispanic—are significant at the 5% level. The AIC and SBC values in Output 11.4.5 are both slightly higher than those from the previous negative binomial model. Therefore, the negative binomial model with spatially weighted regressors provides the best fit thus far.

Because 31% of observations have counts of 0, you might consider a zero-inflated negative binomial (ZINB) model. The following statements fit a ZINB model with local spillovers in the model regressors, with a ZEROMODEL statement to model zero inflation:

proc countreg data=Shigdata Wmat=W;
   model Shigellosis = PopDensity BigHousehold / dist=ZINB;
   zeromodel Shigellosis ~  Hispanic;
   spatialeffects PopDensity BigHousehold;
   spatialzeroeffects Hispanic;
run;

The model fit summary, convergence status, and parameter estimation results are shown in Output 11.4.6.

Output 11.4.6: ZINB Model with Spatially Weighted Regressors

The COUNTREG Procedure

Model Fit Summary
Dependent VariableShigellosis
Number of Observations58
Data SetWORK.SHIGDATA
ModelZINB
ZI Link FunctionLogistic
Log Likelihood-160.43071
Maximum Absolute Gradient4.42772E-6
Number of Iterations24
Optimization MethodNewton-Raphson
AIC338.86142
SBC357.40541

Algorithm converged.

Parameter Estimates
ParameterDFEstimateStandard
Error
t ValueApprox
Pr > |t|
Intercept1-1.9434010.542508-3.580.0003
PopDensity10.2900240.0993472.920.0035
Bighousehold10.2180020.0620993.510.0004
W_PopDensity10.5049030.1655233.050.0023
W_Bighousehold10.2764290.0868603.180.0015
Inf_Intercept1294.88474838.7570757.61<.0001
Inf_Hispanic115.507229192.9065250.080.9359
Inf_W_Hispanic1-41.162731217.771061-0.190.8501
_Alpha10.9138460.2276894.01<.0001


The "Parameter Estimates" table gives the estimate for the spatially weighted regressor from the ZEROMODEL statement, labeled with the prefix "Inf_W_". The estimates of regression coefficients for Inf_Hispanic and Inf_W_Hispanic are insignificant at the 10% level.

Last updated: June 19, 2025