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.
______________________________________________
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html