COUNTREG Procedure

Example 11.2 ZIP and ZINB Models for Data That Exhibit Extra Zeros

(View the complete code for this example.)

In the study by Long (1997) of the number of published articles by scientists (see the section Getting Started: COUNTREG Procedure), the observed proportion of scientists who publish no articles is 0.3005. The following statements use PROC FREQ to compute the proportion of scientists who publish each observed number of articles. Output 11.2.1 shows the results.

proc freq data=long97data;
   table art / out=obs;
run;

Output 11.2.1: Proportion of Scientists Who Publish a Certain Number of Articles

The FREQ Procedure

artFrequency PercentCumulative
Frequency
Cumulative
Percent
027530.0527530.05
124626.8952156.94
217819.4569976.39
3849.1878385.57
4677.3285092.90
5272.9587795.85
6171.8689497.70
7121.3190699.02
810.1190799.13
920.2290999.34
1010.1191099.45
1110.1191199.56
1220.2291399.78
1610.1191499.89
1910.11915100.00


PROC COUNTREG is then used to fit Poisson and negative binomial models to the data. For each model, the PROBCOUNT option computes the probability that the number of published articles is m, for m = 0 to 10. The following statements compute the estimates for Poisson and negative binomial models. The MEAN procedure is then used to compute the average probability of a zero response.

proc countreg data=long97data;
   model art=fem mar kid5 phd ment / dist=poisson;
   output out=predpoi probcount(0 to 10);
run;

proc means mean data=predpoi;
   var p_0;
run;

The output from the Poisson model for the COUNTREG and MEAN procedures is shown in Output 11.2.2.

Output 11.2.2: Poisson Model Estimation

The COUNTREG Procedure

Model Fit Summary
Dependent Variableart
Number of Observations915
Data SetWORK.LONG97DATA
ModelPoisson
Log Likelihood-1651
Maximum Absolute Gradient3.57426E-9
Number of Iterations5
Optimization MethodNewton-Raphson
AIC3314
SBC3343

Algorithm converged.

Parameter Estimates
ParameterDFEstimateStandard
Error
t ValueApprox
Pr > |t|
Intercept10.3046170.1029822.960.0031
fem1-0.2245940.054614-4.11<.0001
mar10.1552430.0613752.530.0114
kid51-0.1848830.040127-4.61<.0001
phd10.0128230.0263970.490.6271
ment10.0255430.00200612.73<.0001

The MEANS Procedure

Analysis Variable
: P_0 Probability
of art taking level=0
Mean
0.2092071


The following statements show the syntax for the negative binomial model:

proc countreg data=long97data plots(only)=profilelike;
   model art=fem mar kid5 phd ment / dist=negbin(p=2) method=qn;
   output out=prednb probcount(0 to 10);
run;

proc means mean data=prednb;
   var p_0;
run;

Output 11.2.3: Profile Likelihood Functions

Profile Likelihood Functions
External File:images/tempb1.png


Output 11.2.3 show the profile likelihood functions of the negative binomial model for the Long (1997) data set, in which each model parameter is varied while holding all others fixed at the MLE. This can serve as a diagnostic tool for model performance, because a large number of flat profile likelihood functions indicates poor optimization results and the resulting MLE should be used with caution.

Output 11.2.4 shows the results of the preceding statements.

Output 11.2.4: Negative Binomial Model Estimation

The COUNTREG Procedure

Model Fit Summary
Dependent Variableart
Number of Observations915
Data SetWORK.LONG97DATA
ModelNegBin(p=2)
Log Likelihood-1561
Maximum Absolute Gradient5.72014E-7
Number of Iterations16
Optimization MethodQuasi-Newton
AIC3136
SBC3170

Algorithm converged.

Parameter Estimates
ParameterDFEstimateStandard
Error
t ValueApprox
Pr > |t|
Intercept10.2561440.1385601.850.0645
fem1-0.2164180.072672-2.980.0029
mar10.1504890.0821061.830.0668
kid51-0.1764150.053060-3.320.0009
phd10.0152710.0360400.420.6718
ment10.0290820.0034708.38<.0001
_Alpha10.4416200.0529678.34<.0001

The MEANS Procedure

Analysis Variable
: P_0 Probability
of art taking level=0
Mean
0.3035957


For each model, the predicted proportion of zero articles can be calculated as the average predicted probability of zero articles across all scientists. Under the Poisson model, the predicted proportion of zero articles is 0.2092, which considerably underestimates the observed proportion. The negative binomial more closely estimates the proportion of zeros (0.3036). Also, the test of the dispersion parameter, _Alpha, in the negative binomial model indicates significant overdispersion (p less-than 0.0001). As a result, the negative binomial model is preferred to the Poisson model.

Another way to account for the large number of zeros in this data set is to fit a zero-inflated Poisson (ZIP) or a zero-inflated negative binomial (ZINB) model. In the following statements, DIST=ZIP requests the ZIP model. In the ZEROMODEL statement, you can specify the predictors, bold z, for the process that generates the additional zeros. The ZEROMODEL statement also specifies the model for the probability phi. By default, a logistic model is used for phi. You can change the default by using the LINK= option. In this particular ZIP model, all variables that are used to model the article counts are also used to model phi.

proc countreg data=long97data;
   model art = fem mar kid5 phd ment / dist=zip;
   zeromodel art ~ fem mar kid5 phd ment;
   output out=predzip probcount(0 to 10);
run;

proc means data=predzip mean;
   var p_0;
run;

The parameters of the ZIP model are displayed in Output 11.2.5. The first set of parameters gives the estimates of bold-italic beta in the model for the Poisson process mean. Parameters that have the prefix "Inf_" are the estimates of bold-italic gamma in the logistic model for phi.

Output 11.2.5: ZIP Model Estimation

The COUNTREG Procedure

Model Fit Summary
Dependent Variableart
Number of Observations915
Data SetWORK.LONG97DATA
ModelZIP
ZI Link FunctionLogistic
Log Likelihood-1605
Maximum Absolute Gradient2.08804E-7
Number of Iterations16
Optimization MethodNewton-Raphson
AIC3234
SBC3291

Algorithm converged.

Parameter Estimates
ParameterDFEstimateStandard
Error
t ValueApprox
Pr > |t|
Intercept10.6408380.1213065.28<.0001
fem1-0.2091450.063405-3.300.0010
mar10.1037510.0711111.460.1446
kid51-0.1433200.047429-3.020.0025
phd1-0.0061660.031008-0.200.8424
ment10.0180980.0022957.89<.0001
Inf_Intercept1-0.5770600.509383-1.130.2573
Inf_fem10.1097470.2800820.390.6952
Inf_mar1-0.3540130.317611-1.110.2650
Inf_kid510.2171010.1964811.100.2692
Inf_phd10.0012720.1452620.010.9930
Inf_ment1-0.1341140.045244-2.960.0030

The MEANS Procedure

Analysis Variable
: P_0 Probability
of art taking level=0
Mean
0.2985679


The proportion of zeros that are predicted by the ZIP model is 0.2986, which is much closer to the observed proportion than the Poisson model. But Output 11.2.7 shows that both models deviate from the observed proportions at one, two, and three articles.

The ZINB model is specified by the DIST=ZINB option. All variables are again used to model both the number of articles and phi. The METHOD=QN option specifies that the quasi-Newton method be used to fit the model rather than the default Newton-Raphson method. These options are implemented in the following statements:

proc countreg data=long97data;
   model art=fem mar kid5 phd ment / dist=zinb method=qn;
   zeromodel art ~ fem mar kid5 phd ment;
   output out=predzinb probcount(0 to 10);
run;

proc means data=predzinb mean;
   var p_0;
run;

The estimated parameters of the ZINB model are shown in Output 11.2.6. The test for overdispersion again indicates a preference for the negative binomial version of the zero-inflated model (p less-than 0.0001). The ZINB model also does a good job of estimating the proportion of zeros (0.3119), and it follows the observed proportions well, though possibly not as well as the negative binomial model.

Output 11.2.6: ZINB Model Estimation

The COUNTREG Procedure

Model Fit Summary
Dependent Variableart
Number of Observations915
Data SetWORK.LONG97DATA
ModelZINB
ZI Link FunctionLogistic
Log Likelihood-1550
Maximum Absolute Gradient0.00974
Number of Iterations81
Optimization MethodQuasi-Newton
AIC3126
SBC3189

Algorithm converged.

Parameter Estimates
ParameterDFEstimateStandard
Error
t ValueApprox
Pr > |t|
Intercept10.4167500.1435962.900.0037
fem1-0.1955080.075592-2.590.0097
mar10.0975810.0844521.160.2479
kid51-0.1517330.054206-2.800.0051
phd1-0.0007000.036270-0.020.9846
ment10.0247860.0034937.10<.0001
Inf_Intercept1-0.1916571.322809-0.140.8848
Inf_fem10.6359330.8489130.750.4538
Inf_mar1-1.4994970.938666-1.600.1102
Inf_kid510.6284380.4427811.420.1558
Inf_phd1-0.0377200.308006-0.120.9025
Inf_ment1-0.8822970.316223-2.790.0053
_Alpha10.3766810.0510297.38<.0001

The MEANS Procedure

Analysis Variable
: P_0 Probability
of art taking level=0
Mean
0.3119487


The following statements compute the average predicted count probability across all scientists for each count 0, 1, …, 10. The averages for each model, along with the observed proportions, are then arranged for plotting by PROC SGPLOT.

proc summary data=predpoi;
   var p_0-p_10;
   output out=mnpoi mean(p_0-p_10)=mn0-mn10;
run;
proc summary data=prednb;
   var p_0-p_10;
   output out=mnnb mean(p_0-p_10)=mn0-mn10;
run;
proc summary data=predzip;
   var p_0-p_10;
   output out=mnzip mean(p_0-p_10)=mn0-mn10;
run;
proc summary data=predzinb;
   var p_0-p_10;
   output out=mnzinb mean(p_0-p_10)=mn0-mn10;
run;


data means;
   set mnpoi mnnb mnzip mnzinb;
   drop _type_ _freq_;
run;

proc transpose data=means out=tmeans;
run;

data allpred;
   merge obs(where=(art<=10)) tmeans;
   obs=percent/100;
run;

proc sgplot;
   yaxis label='Probability';
   xaxis label='Number of Articles';
   series y=obs  x=art / name='obs' legendlabel='Observed'
      lineattrs=(color=black thickness=4px);
   series y=col1 x=art / name='poi' legendlabel='Poisson'
      lineattrs=(color=blue);
   series y=col2 x=art/ name='nb' legendlabel='Negative Binomial'
      lineattrs=(color=red);
   series y=col3 x=art/ name='zip' legendlabel='ZIP'
      lineattrs=(color=blue pattern=2);
   series y=col4 x=art/ name='zinb' legendlabel='ZINB'
      lineattrs=(color=red pattern=2);
   discretelegend 'poi' 'zip' 'nb' 'zinb' 'obs' / title='Models:'
      location=inside position=ne across=2 down=3;
run;

For each of the four fitted models, Output 11.2.7 shows the average predicted count probability for each article count across all scientists. The Poisson model clearly underestimates the proportion of zero articles published, whereas the other three models are quite accurate at zero. All the models do well at the larger numbers of articles.

Output 11.2.7: Average Predicted Count Probability

Average Predicted Count Probability


Last updated: June 19, 2025