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
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.