In reference to my earlier post
http://www.stata.com/statalist/archive/2007-01/msg00442.html I managed to
convert the hnblogit module to work with Version 8. In case anyone is
interested, it turned out to be quite simple with only trivial changes:
* I removed properties(svyb svyj svyr) as suggested by Michael Blasnik,
disabling survey-related capabilities.
* I changed the 'cilevel' option descriptor (new to V9) to 'integer 95'
* flagged the program as Version 8
* the jhnb_logit_ll ado file did not need modification except to flag it as
Version 8, which I've done (and renamed it as nb_logit_ll8 to avoid
confusion)
* there was no problem with the passthru command - the cluster option worked
fine.
Here are the edited ado files (I based it on Professor Hilbe's hnblogit
V1.0.0 rather than V1.1 just for simplicity)
Thanks again for everyone's help.
Peter Siminski.
*! Version 1.0.0
* NEGATIVE BINOMIAL-LOGIT HURDLE REGRESSION FOR V8: Joseph Hilbe :
7Oct2005
* modified slightly by Peter Siminski 24Jan2007 so that it works with Stata
V8
program hnblogit8, eclass
version 8
syntax [varlist] [if] [in] [fweight pweight aweight iweight] [, ///
CENsor(string) Level(integer 95) ///
OFFset(passthru) EXposure(passthru) ///
CLuster(passthru) IRr Robust noLOG FROM(string asis) * ]
gettoken lhs rhs : varlist
mlopts mlopts, `options'
if ("`weight'" != "") local weight "[`weight' `exp']"
if (`"`from'"' != `""') local initopt `"init(`from')"'
ml model lf nb_logit_ll8 (logit: `lhs' = `rhs', `offset' `exposure')
///
(negbinomial: `lhs' = `rhs', `offset' `exposure') /lnalpha
///
`if' `in' `weight', ///
`mlopts' `robust' `cluster' ///
title("Negative Binomial-Logit Hurdle Regression") ///
maximize `log' `initopt' ///
ereturn scalar k_aux = 1
ml display, level(`level') `irr'
qui {
* AIC
tempvar aic
local nobs e(N)
local npred e(df_m)
local df = e(N) - e(df_m) -1
local llike e(ll)
gen `aic' = ((-2*`llike') + 2*(`npred'+1))/`nobs'
}
di in gr _col(1) "AIC Statistic = " in ye %9.3f `aic'
end
*! version 1.0.0 30Sep2005
* Negative Binomial-Logit Hurdle: log likelihood function :Joseph Hilbe
program define nb_logit_ll8
version 8
args lnf beta1 beta2 alpha
tempvar pi mu a
qui gen double `a' = exp(`alpha')
qui gen double `pi' = exp(`beta1')
qui gen double `mu' = exp(`beta2') * `a'
qui replace `lnf' = cond($ML_y1==0, ln(1/(1+`pi')), ln(`pi'/(1+`pi')) +
///
$ML_y1 * ln(`mu'/(1+`mu')) - ///
ln(1+`mu')/`a' + lngamma($ML_y1 + 1/`a') - ///
lngamma($ML_y1 + 1) - lngamma(1/`a') - ///
ln(1-(1+`mu')^(-1/`a') ) )
end
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/