CNTSELECT Procedure
Example 10.1 Zero-Inflated Poisson Model with CLASS Statement
This example shows how to use the CNTSELECT procedure to estimate a zero-inflated Poisson model with a classification variable Group that has two levels. The following DATA step generates 10,000 replicates from the zero-inflated Poisson (ZIP) model. The first 5,000 replicates belong to the first group, and the second 5,000 replicates belong to the second group. The model contains seven variables and three variables that correspond to the zero-inflated process.
data simulate;
call streaminit(12345);
array vars x1-x7;
array zero_vars z1-z3;
array parms{7} (.3 .4 .2 .4 -.3 -.5 -.3);
array zero_parms{3} (-.6 .3 .2);
intercept=0.5;
group=1;
z_intercept=-1;
theta=0.5;
do i=1 to 10000;
sum_xb=0;
sum_gz=0;
if i>5000 then do;
intercept=2;
group=2;
end;
do j=1 to 7;
vars[j]=rand('NORMAL',0,1);
sum_xb=sum_xb+parms[j]*vars[j];
end;
mu=exp(intercept+sum_xb);
y_p=rand('POISSON', mu);
do j=1 to 3;
zero_vars[j]=rand('NORMAL',0,1);
sum_gz = sum_gz+zero_parms[j]*zero_vars[j];
end;
z_gamma = z_intercept+sum_gz;
pzero = cdf('LOGISTIC',z_gamma);
cut=rand('UNIFORM');
if cut<pzero then y_p=0;
output;
end;
keep y_p group x1-x7 z1-z3;
run;
You can load the data set simulate into a data table in your session that is associated with the mylib libref. The DATA step assumes that your libref is named mylib, but you can substitute any appropriately defined libref.
data mylib.simulate;
set simulate;
run;
The following statements estimate a zero-inflated Poisson model with the classification variable Group:
proc cntselect data=mylib.simulate dist=zip;
class group;
model y_p=group x1-x7;
zeromodel y_p ~ z1-z3;
run;
Output 10.1.1 shows the results for the zero-inflated Poisson model.
Output 10.1.1: Zero-Inflated Poisson Model with CLASS Statement
| Class Level Information | ||
|---|---|---|
| Class | Levels | Values |
| group | 2 | 1 2 |
| Model Fit Summary | |
|---|---|
| Dependent Variable | y_p |
| Number of Observations | 10000 |
| Data Set | SIMULATE |
| Model | ZIP |
| ZI Link Function | Logistic |
| Log Likelihood | -18176.3 |
| Maximum Absolute Gradient | 0.001931 |
| Number of Iterations | 7 |
| Optimization Method | Newton-Raphson |
| AIC | 36378.62 |
| SBC | 36472.35 |
| Covariance Estimation | Hessian |
| Convergence criterion (FCONV=1E-8) satisfied. |
| Parameter Estimates | |||||
|---|---|---|---|---|---|
| Parameter | DF | Estimate | Standard Error | t Value | Approx Pr > |t| |
| Intercept | 1 | 2.001286 | 0.006746 | 296.67 | <.0001 |
| group 1 | 1 | -1.491903 | 0.012383 | -120.48 | <.0001 |
| group 2 | 0 | 0 | . | . | . |
| x1 | 1 | 0.296633 | 0.004628 | 64.09 | <.0001 |
| x2 | 1 | 0.400643 | 0.004607 | 86.96 | <.0001 |
| x3 | 1 | 0.196278 | 0.004592 | 42.74 | <.0001 |
| x4 | 1 | 0.394971 | 0.004644 | 85.05 | <.0001 |
| x5 | 1 | -0.299776 | 0.004508 | -66.50 | <.0001 |
| x6 | 1 | -0.497570 | 0.004809 | -103.47 | <.0001 |
| x7 | 1 | -0.295755 | 0.004510 | -65.57 | <.0001 |
| Inf_Intercept | 1 | -0.969211 | 0.028573 | -33.92 | <.0001 |
| Inf_z1 | 1 | -0.609492 | 0.029128 | -20.92 | <.0001 |
| Inf_z2 | 1 | 0.298572 | 0.027039 | 11.04 | <.0001 |
| Inf_z3 | 1 | 0.208062 | 0.026557 | 7.83 | <.0001 |
The "Class Level Information" table shows that the classification variable Group has two levels. The "Model Fit Summary" table shows detailed information about the model and indicates that all 10,000 observations were used to fit the model. All parameter estimates in the "Parameter Estimates" table are highly significant and correspond to their theoretical values set during the data generating process.