/* Adapted from code provide by Dale McLerran of */ /* Fred Hutchinson Cancer Research Center */ data test; /* We set a seed here; trying to use the default seed=0 within the */ /* DO loop doesn't work well */ seed=12345679; /* Generate a ZIP sample with a mixing proportion */ /* p0 of .5 and a Poisson mean lambda of 2 */ p0=.5; do i=1 to 100; /* Generate the Bernoulli mixing random variable */ call ranbin(seed,1,p0,zero_inflate); lambda=2; /* Generate the response */ if zero_inflate then y=0; else call ranpoi(seed,lambda,y); output; end; keep y lambda; run; /* Fit the model in NLMIXED. Use the same start */ /* values as in the algorithm that created the file */ proc nlmixed data=test; parms p0=.5 mu0=2; if y=0 then prob=p0+(1-p0)*exp(-mu0); if y=0 then loglike=log(prob); else loglike=log(1-p0)+y*log(mu0)-mu0-lgamma(y+1); model y~general(loglike); run;