* 0_truncated negative binomial log likelihood function
* 17Feb1998 Joseph Hilbe

program define nbin0lf
 tempvar mu a
 qui {
     local lnf    "`1'"
     local I      "`2'"
     local alpha  "`3'"
     if "$S_mloff" != "" {
       tempvar Io
       qui gen double `Io' = `I' + $S_mloff
     }
     else  local Io "`I'"
     gen double `a' = exp(`alpha')
     gen double `mu' = exp(`Io') * `a'
     replace `lnf' = $S_mldepn * ln(`mu'/(1+`mu'))   - /*
     */  ln(1+`mu')/`a' + lngamma($S_mldepn + 1/`a') - /*
     */  lngamma($S_mldepn + 1) - lngamma(1/`a')  -    /*
     */  ln(1-(1+`mu')^(-1/`a'))
  }
end