d log gamma
).
d^2 log gamma
).
pm_gen
, ph_gen
and nbh_gen
need
functions to generate random numbers from the Poisson and Gamma distributions.
For this reason, they must be run either under OCTAVE version 2.014 (or above)
or with MATLAB equipped with the Statistics
Toolbox.
gsl_randist
which can be used directly for
simulating random numbers from the command line (if you are courageous and have
a decent C compiler, you can also use the GSL library modules for writing a mex
file). Linux users should find this packaged in any recent version of their
favorite distribution under the name gsl
or gsl-bin
(Debian).
The function nbh_em
uses a modified version of the EM algorithm in which
after the E step, the EM intermediate quantity is maximized explicitly with
respect to the beta
parameters while the alpha
parameters are
updated using a single Newton step. The first and second derivative of the part
of the EM intermediate quantity which depends on the alpha
parameters
are computed using the special functions digamma
and trigamma
.
See [11] for details concerning the convergence of such modified
versions of EM.
If you are using OCTAVE, you will also need the gammaln
m-file (which
computes the log of the gamma function) to run ph_em
, ph_vit
,
nbh_em
or nbh_vit
. This function is in the subdirectory
h2m/octave
which you should thus append to your loadpath using the
path
command.
nb_ml
and nbh_em
without checking that the objective function
indeed increases and that alpha does not become negative. This is of course
something that could break down convergence (and at least make the likelihood
non strictly increasing from one iteration to the other). Note that it is
easily checked though that in both cases, the part of the likelihood or of the
EM intermediate quantity which depends only on alpha
is concave, and
thus the situation is rather easy compared to a general optimization task.
In practice problems never seem to happen as long that you have at least a few
non null observations and that your starting values are not too crazy when
using nbh_em
(for real data, you can for instance use nb_ml
to
obtain credible initialization values). If you see the message
Warning: could not update alphatoo often when using
nbh_em
then you are probably in one of those bad
cases and should check your starting values (the other option is that you have
very few data points - say less than 10 - and/or that these are almost all
zero, in which case there is not much to be expected from estimating the
parameters anyway).
Olivier Cappé, Aug 24 2001