Hi Peter,
The main code calls another file which is a loglikelihood.
I think that you could create a similar program for v8
but you may change slighly the option of the maximization.
In other words, change the version in the file:
jhnb_logit_ll.ado and pay attention in
hnblogit.ado.
Good luck, R.
----- Original Message -----
From: "Peter Siminski" <[email protected]>
To: <[email protected]>
Sent: Monday, January 15, 2007 10:46 PM
Subject: st: How can I use this V9 module (hnblogit) with Version 8.0?
Dear experienced Stata users,
After a couple of years of putting it off, I have recently started using
Stata. Joseph Hilbe has writted a module "hnblogit" which would be very
useful for my PhD research. It is listed as a Version 9 module.
Unfortunately, the Australian Bureau of Statistics holds data which
currently I can only access remotely using Stata V8.0. I would be very
grateful if somebody could tell me if this module would work in V8.0 if I
simply changed the "Version 9.1" line to "Version 8.0". If not, is the code
easily modifiable to make it work?
Thanks in advance,
Peter.
Peter Siminski
PhD Student
Social Policy Research Centre
University of New South Wales, Australia
[email protected]
P.S. Here are the two ado-files which make up the hnblogit module (sourced
from http://econpapers.repec.org/software/bocbocode/s456401.htm ):
*! Version 1.0.0
* NEGATIVE BINOMIAL-LOGIT HURDLE REGRESSION : Joseph Hilbe : 7Oct2005
program hnblogit, eclass properties(svyb svyj svyr)
version 9.1
syntax [varlist] [if] [in] [fweight pweight aweight iweight] [, ///
CENsor(string) Level(cilevel) ///
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 jhnb_logit_ll (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 jhnb_logit_ll
version 9
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/
*
* 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/