eems icon indicating copy to clipboard operation
eems copied to clipboard

parameterization of negative-bi loglikelihood

Open halasadi opened this issue 7 years ago • 1 comments

Here in the code is the log-likelihood of the NegBi up to a constant (where prob, size) are treated as constants

*
 Log probability mass function of the negative binomial distribution, with
 parameters size (number of failures) and prob (probability of success)
 Also -- log pmf of the zero-truncated negative binomial, with the same parameters,
 as long as k>0, since truncating only changes the constant of proportionality
 Uses gamma(n) = (n-1)!
 */
double dnegbinln(const int k, const int size, const double prob) {
    double pln = -Inf;
    if ( (k>=0) && (size>0) && (prob>0) && (prob<1) ) {
        pln = lgamma(size+k) - lgamma(k+1) + k*log(prob);
    }
    return (pln);
}

However, shouldn't it be

pln = lgamma(size+k) - lgamma(k+1) + k*log(1-prob);

So I think the eems implementation has p as the probability of failure (not the probability of success).

halasadi avatar Dec 08 '17 17:12 halasadi

I am using the Wikipedia article as a reference: https://en.wikipedia.org/wiki/Negative_binomial_distribution

halasadi avatar Dec 08 '17 17:12 halasadi