I am looking for code that allows for a more flexible negative binomial model (similar to Stata's "gnbreg"). In particular, I am looking to be able to model the ancillary shape parameter in terms of a series of covariates. So if, y[i] ~ poisson(mu[i]) mu[i] = exp(x[i]beta + u[i]) exp(u[i]) ~ Gamma(1/alpha, alpha) I am looking to parameterize alpha as exp(z[i]gamma). If you are familiar with a package that allows for this, I'd appreciate the heads up. Similar information that allows for first differences with such a model is also appreciated. Thanks. Erin --------------- Erin M Simpson esimpson at fas.harvard.edu http://people.fas.harvard.edu/~esimpson
generalized negative binomial
3 messages · Erin M Simpson, Brian Ripley, Spencer Graves
On Sat, 12 Mar 2005, Erin M Simpson wrote:
I am looking for code that allows for a more flexible negative binomial model (similar to Stata's "gnbreg").
Your subject line is not clear to me: Stata appears to fit a negative
binomial model, the point being that it is not a glm as fitted by glm.nb.
(So when Stata says
`gnbreg is a generalized negative binomial regression'
it is `regression' not `negative binomial' that is being generalized.)
In particular, I am looking to be able to model the ancillary shape parameter in terms of a series of covariates. So if, y[i] ~ poisson(mu[i]) mu[i] = exp(x[i]beta + u[i]) exp(u[i]) ~ Gamma(1/alpha, alpha) I am looking to parameterize alpha as exp(z[i]gamma). If you are familiar with a package that allows for this, I'd appreciate the heads up. Similar information that allows for first differences with such a model is also appreciated.
Just write down the log-likelihood (I am not sure what the free parameters here are: are beta and gamma vectors?), and call optim() to maximize it.
Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595
I whole-heartedly endorse Prof. Ripley's suggestion to write down
the log(likelihood) and use optim; I've done that many times with
seemingly good results. For confidence intervals, the best procedure is
to use 2*log(likelihood ratio) being approximately chi-square. If you
are estimating two parameters, you can easily compute log(likelihood)
for a grid of points about the maximum likelihood estimates (MLEs) and
use "contour" to draw lines at the difference confidence levels. You
can also use the argument "hessian = TRUE" to get the observed
information matrix and therefore also the covariance matrix of the
standard asymptotic normal approximation to the distribution of the
MLEs; I've done both.
hope this helps. spencer graves
Prof Brian Ripley wrote:
On Sat, 12 Mar 2005, Erin M Simpson wrote:
I am looking for code that allows for a more flexible negative binomial model (similar to Stata's "gnbreg").
Your subject line is not clear to me: Stata appears to fit a negative
binomial model, the point being that it is not a glm as fitted by
glm.nb. (So when Stata says
`gnbreg is a generalized negative binomial regression'
it is `regression' not `negative binomial' that is being generalized.)
In particular, I am looking to be able to model the ancillary
shape parameter in terms of a series of covariates. So if,
y[i] ~ poisson(mu[i])
mu[i] = exp(x[i]beta + u[i])
exp(u[i]) ~ Gamma(1/alpha, alpha)
I am looking to parameterize alpha as exp(z[i]gamma).
If you are familiar with a package that allows for this, I'd appreciate
the heads up. Similar information that allows for first differences
with
such a model is also appreciated.
Just write down the log-likelihood (I am not sure what the free parameters here are: are beta and gamma vectors?), and call optim() to maximize it.