CNTSELECT Procedure

Example 10.2 Zero-Inflated Poisson Model with BAYES and PRIOR Statements

This example shows how to use the CNTSELECT procedure to estimate a zero-inflated Poisson model by using Bayesian methods, with user-specified priors. The following DATA step generates 1,000 replicates from the zero-inflated Poisson (ZIP) model. The model contains seven variables and three variables that correspond to the zero-inflated process.

data bayes_ex;
   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 1000;
      sum_xb=0;
      sum_gz=0;
      if i>500 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 bayes_ex 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.bayes_ex;
   set bayes_ex;
run;

The following statements estimate a zero-inflated Poisson model via Bayesian analysis. Note that the BAYES statement controls the settings for the MCMC sampler and determines which Bayesian output to produce. The PRIOR statements set the prior distributions for the parameters.

proc cntselect data=mylib.bayes_ex dist=zip;
   class group;
   model y_p=group x1-x7;
   zeromodel y_p ~ z1-z3;
   bayes seed = 81239 nmc = 10000 sampler = rwm(ntu = 50) priorsummary(shownames);
   prior x1-x7 ~ normal(mean = 0, sd = 10);
   prior group_1 ~ normal(mean = 0, sd = 10, upper = 0);
   prior Intercept ~ normal(mean = 0, sd = 10);
   prior Inf_z1-Inf_z3 ~ normal(mean = 0, sd = 1);
   prior Inf_Intercept ~ normal(mean = 0, sd = 10);
run;

Output 10.2.1 shows the results for the zero-inflated Poisson model. The "Prior Summary" table shows detailed information about prior distributions for the parameters in the model. The "Posterior Summaries" table contains two point estimates of the parameters from the posterior samples: the posterior mean and the posterior median (50th percentile). The "MCMC Diagnostic Summaries" table contains basic convergence diagnostics to check whether the Markov chain has converged and whether the sample size is sufficient.

Output 10.2.1: Bayesian Estimation of Zero-Inflated Poisson Model

The CNTSELECT Procedure

Prior Summary
ParameterNamePriorBoundsHyperparameters
LowerUpperNameValueNameValue
InterceptInterceptNormal-InftyInftyMean0Variance100
group 1group_1Truncated Normal-Infty0Mean0Variance100
x1x1Normal-InftyInftyMean0Variance100
x2x2Normal-InftyInftyMean0Variance100
x3x3Normal-InftyInftyMean0Variance100
x4x4Normal-InftyInftyMean0Variance100
x5x5Normal-InftyInftyMean0Variance100
x6x6Normal-InftyInftyMean0Variance100
x7x7Normal-InftyInftyMean0Variance100
Inf_InterceptInf_InterceptNormal-InftyInftyMean0Variance100
Inf_z1Inf_z1Normal-InftyInftyMean0Variance1
Inf_z2Inf_z2Normal-InftyInftyMean0Variance1
Inf_z3Inf_z3Normal-InftyInftyMean0Variance1

The CNTSELECT Procedure

Posterior Summaries
ParameterNMeanStandard
Deviation
Percentiles
2.5%25%50%75%97.5%
Intercept100001.98000.01311.95541.97071.97981.98852.0070
group 110000-1.48280.0325-1.5405-1.5090-1.4833-1.4584-1.4188
x1100000.28530.01310.26050.27680.28510.29400.3121
x2100000.41460.01070.39300.40810.41450.42190.4356
x3100000.21290.01160.19010.20520.21340.22080.2362
x4100000.40270.009980.38190.39710.40260.40880.4217
x510000-0.31070.0129-0.3358-0.3196-0.3101-0.3022-0.2849
x610000-0.51880.0118-0.5427-0.5270-0.5186-0.5109-0.4962
x710000-0.29630.0123-0.3186-0.3053-0.2967-0.2882-0.2720
Inf_Intercept10000-1.00550.0669-1.1440-1.0509-1.0016-0.9554-0.8867
Inf_z110000-0.57490.0791-0.7243-0.6287-0.5779-0.5268-0.3997
Inf_z2100000.40130.09140.22810.33460.39990.46170.5850
Inf_z3100000.37610.05500.27360.33420.37370.41680.4807

The CNTSELECT Procedure

MCMC Diagnostic Summaries
ParameterMCSEMCSE/SDESSAutocorrelation
Time
ESS/N
Intercept*0.001700.130059.1948168.90.00592
group 1*0.006320.194326.4872377.50.00265
x1*0.001710.130758.4973170.90.00585
x2*0.0008410.0787161.661.86940.0162
x3 0.0007260.0624257.038.90910.0257
x4*0.001230.122866.2673150.90.00663
x5*0.001600.124264.7892154.30.00648
x6*0.001430.121467.9022147.30.00679
x7*0.001110.0904122.581.64160.0122
Inf_Intercept*0.009670.144547.8864208.80.00479
Inf_z1*0.01110.140550.6374197.50.00506
Inf_z2*0.01300.141849.7432201.00.00497
Inf_z3*0.009610.174932.7080305.70.00327
 *Autocorrelation Remains


Last updated: July 09, 2026