Next: To do Up: Reference Previous: Functions in the main

Subsections


Functions in the H2M/cnt extension

Alphabetical list of functions

ex_cnt
Script to illustrate the three basic models handled by H2M/cnt.
nbh_chk
Checks the parameters of a negative binomial HMM and returns its dimension.
ph_chk
Checks the parameters of a Poisson HMM and returns its dimension.
nb_ml
Maximum likelihood estimation for negative binomial data.
pm_gen
Simulates data from a Poisson mixture.
ph_vit
A posteriori sequence estimation for Poisson HMM.
nbh_em
Estimates the parameters of a negative binomial HMM using EM.
nbh_vit
A posteriori sequence estimation for negative binomial HMM.
nbh_gen
Simulates data from a negative binomial HMM.
pm_em
Estimates the parameters of a Poisson mixture using the EM algorithm.
ph_em
Estimates the parameters of a Poisson HMM using the EM algorithm.
ph_gen
Simulates data from a Poisson HMM.
pm_chk
Checks the parameters of a Poisson mixture and returns its dimension.
digamma
Computes the digamma (also called psi) function (d log gamma).
trigamma
Computes the trigamma function (d^2 log gamma).


Notes

The simulation routines 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.
If you do not fall into one of the two cases above (which probably means that you are using MATLAB but don't want to pay for the Statistics toolbox), you can still get around using the free Statbox toolbox by Gordon K Smyth but you will have to modify the names of the random number generators. Another option, would be to use GSL - The GNU Scientific Library whose recent versions contain a compiled binary named 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.

Known problems

To avoid the use of a line search routine, the Newton steps are used in 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 alpha
too 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).


Next: To do Up: Reference Previous: Functions in the main

Olivier Cappé, Aug 24 2001