This FAQ page will show how to code zero-truncated count models using SAS proc nlmixed. We will cover zero-truncated poisson and zero-truncated negative binomial regression models.
Both models use the same dataset, medpar.sas7bdat, and the same predictor variables, died, hmo and dummy variables type2 and type3. For each of the models we will give only partial output, primarily estimates, standard errors, wald tests and p-values so that you will be able to compare the results with ordinary poisson and negative binomial models.
Zero-truncated poisson regression
We will begin with the zero-truncated poisson regression. The setup for nlmixed is very straightforward with xb being the linear predictor with parameters b0 (the intercept) and b1 through b4 as the regression coefficients. By using nlmixed we will obtain an iterated maximum likelihood solution for the model.
options nocenter; proc nlmixed data="D:datamedpar.sas7bdat"; xb = b0 + b1*died + b2*hmo + b3*type2 + b4*type3; ll = los*xb - exp(xb) - lgamma(los + 1) - log(1-exp(-exp(xb))); model los ~ general(ll); run; /* partial output */ Fit Statistics -2 Log Likelihood 9475.1 AIC (smaller is better) 9487.1 AICC (smaller is better) 9487.1 BIC (smaller is better) 9518.9 Parameter Estimates Standard Parameter Estimate Error DF t Value Pr > |t| Alpha Lower Upper Gradient b0 2.2645 0.01182 1495 191.51 <.0001 0.05 2.2413 2.2877 -0.00649 b1 -0.2487 0.01812 1495 -13.73 <.0001 0.05 -0.2842 -0.2131 -0.00345 b2 -0.07551 0.02394 1495 -3.15 0.0016 0.05 -0.1225 -0.02856 -0.0016 b3 0.2501 0.02099 1495 11.91 <.0001 0.05 0.2089 0.2912 -0.00285 b4 0.7504 0.02624 1495 28.59 <.0001 0.05 0.6989 0.8019 0.001308
Thus, our model looks like this, xb = 2.2645 - .2487*died - .07551*hmo + .2501*type2 + .7504*type3.
Zero-truncated negative binomial regression
Our second model is a zero-truncated negative binomial regression which has one additional parameter, alpha. alpha is a measure of overdispersion. If overdispersion (alpha) is zero then the negative binomial model is equivalent to a poisson model.
proc nlmixed data="D:datamedpar.sas7bdat"; xb = b0 + b1*died + b2*hmo + b3*type2 + b4*type3; mu = exp(xb); m = 1/alpha; ll = lgamma(los+m)-lgamma(los+1)-lgamma(m) + los*log(alpha*mu)-(los+m)*log(1+alpha*mu) - log(1 -( 1 + alpha*mu)**(-m)); model los ~ general(ll); run; /* partial output */ Fit Statistics -2 Log Likelihood 13693 AIC (smaller is better) 13703 AICC (smaller is better) 13703 BIC (smaller is better) 13730 Parameter Estimates Standard Parameter Estimate Error DF t Value Pr > |t| Alpha Lower Upper Gradient b0 2.2240 0.03002 1495 74.08 <.0001 0.05 2.1651 2.2829 -0.00029 b1 -0.2522 0.04471 1495 -5.64 <.0001 0.05 -0.3399 -0.1645 -0.00088 b2 -0.07542 0.05823 1495 -1.30 0.1955 0.05 -0.1897 0.03881 -0.00099 b3 0.2685 0.05500 1495 4.88 <.0001 0.05 0.1606 0.3764 0.000382 b4 0.7668 0.08304 1495 9.23 <.0001 0.05 0.6039 0.9297 -0.00067 alpha 0.5325 0.02928 1495 18.19 <.0001 0.05 0.4751 0.5900 -0.0032
The way to test whether alpha is different from zero is to compute the difference in the -2 Log Likelihood values for the zero-truncated poisson and the zero-truncated negative binomial. In this example the computation looks like this, (13693-9475.1) = 4217.9, which is distributed as a chi-square with one degree of freedom. Clearly, there is overdispersion in this example.