Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Negative binomial GLM with offset

166 views
Skip to first unread message

shawn....@ttu.edu

unread,
Oct 19, 2006, 5:59:26 PM10/19/06
to
Dear Matlab users:

I need to conduct a Monte Carlo power analysis (for AICc stats) for
some count data with assumed negbin error terms. Also, my counts are
standardized by an offset term for effort. All i really need to do is
generate randomly distributed data of Y|X from a known quadratic
function (determined already in SAS Proc Genmod but would be nice to
verify 1st in Matlab before randomization) and determine
log-likelihoods (or neg-LL) from 3 models: an intercept-only fully
reduced model, a model with single linear effect, and a model with
quadratic and linear terms (i.e., just one response and predictor
variables). As you probably know, the glmfit.m function supports an
offset but not the negbin pdf, and the nbinfit.m function estimates
parameters by MLE but does not support an offset - it will not take the
non-integer data created when I divide my counts by the offset vector.
While I can probably cannabilize code from these and other negbin
functions (e.g., nbinpdf), I am guessing that this problem has already
been approached by several others. I am not a statistician by trade
and am an intermediate brute force Matlab programmer. I can probably
figure this out but it would save me many hours if anyone has code
already or some useful suggestions. I have browsed thru the negbin
related messages in this group and not found any GLM specific questions
- hope I haven't missed anything. thanks. SH

Peter Perkins

unread,
Oct 23, 2006, 1:21:45 PM10/23/06
to
Shawn, as you point out, NBINFIT fits a negative binomial distribution but does
not do regression nor allow an offset term, and GLMFIT fits a regression model
and allows an offset, but not for NB because that's not a generalized linear
model unless you fix the variance parameter.

The method for NB regression that I am familiar with is basically an iteration
back and forth between fitting a NB GLM with a fixed variance parameter, and
then estimating a new value for that parameter based on the previous GLM fit. I
believe that McCullagh&Nelder's Generalized Linear Models book describes this
method. GLMFIT does allow you to define a new family, so I think this is mostly
an exercise in finding the right section in M&N. I can probably put my hands on
the right information if that's the method you want to go with, and don't have
the right references.

You could also fit using maximum likelihood by "brute force", i.e., just use
FMINCON or FMINSEARCH on the full log-likelihood. I believe that maximum
likelihood is not considered the best way to estimate the variance parameter,
but I don't have the references at hand right now.

Hope this helps.

- Peter Perkins
The MathWorks, Inc.

Surojit Biswas

unread,
Mar 5, 2013, 5:10:10 PM3/5/13
to
Hi,

I'm sure you've already found a solution to your problem, but in case anyone has similar problems please have a look at a Negative-Binomial regression routine that I've written and use often for my research:

http://www.mathworks.com/matlabcentral/fileexchange/40642-negative-binomial-regression

Thanks,
Surge

shawn....@ttu.edu wrote in message <1161295166....@m73g2000cwd.googlegroups.com>...
0 new messages