2
$\begingroup$

I am trying to maximize a Poisson likelihood function for an array of values, of the form

llhij = -mij + kij*ln(mij/kij).

(where I use the numerical approximation ln(k!) ~ k*ln(k)).

For my purposes, the mij are the number of events predicted by a model, and the kij are the number of events observed. For the total log-likelihood, I sum the likelihoods of all elements of the array.

In some cases, the m = k = 0, and the log likelihood becomes (-Inf - -Inf) = NaN.

Is it an acceptable solution to deal with this by replacing the NaN values with zero? The way that I have implemented this solution in my (Matlab) code (following an example from a similar analysis) is

if(any(isnan(llh(:))))
llh(isnan(llh)) = 0;
end

...

m = sum(sum(llh, 1),2);

If I do not reset the NaN values of the likelihood, the entire llh is returned as NaN and the maximization fails.

By setting the NaN elements of the likelihood array to zero, this procedure effectively causes the elements that would be NaN to be ignored in the analysis, but I am having difficulty justifying this procedure, and am concerned that it introduces or ignores errors later in the analysis (the point is to calculate a set of confidence intervals in addition to the MLE, and the intervals are quite large where they should be essentially zero).

Is this a conceptually acceptable way to deal with these NaN elements, and if not, is there a more formal solution?

$\endgroup$
3
  • 2
    $\begingroup$ How can cases with $k=m=0$ possibly be part of the likelihood? What information do you get when the model says nothing will appear and nothing appears? (A Poisson model with a parameter of $0$ assigns all the probability to $0$, after all.) The only place you can run into trouble is where the model predicts nothing will appear and something does: that would be definitive evidence the model is wrong. $\endgroup$
    – whuber
    Commented Jun 23, 2016 at 20:42
  • $\begingroup$ I am concerned that by just dropping these bins, without any further action, I am not taking an adequate statistical penalty for the loss of information. I also don't fully understand the term "statistical penalty"; I had the impression that not only am I unable to use that bin to provide the statistics needed to tighten my confidence intervals, I also need to analytically account for the fact that this bin cannot be used. For example, my implementation also explicitly sets some elements of the array to zero if we don't want them to count, such as in the case a detector is bad. $\endgroup$
    – Danielle
    Commented Jun 24, 2016 at 1:21
  • $\begingroup$ I am trying to understand if this is statistically the correct thing to do, or if it introduces an unfair "cheat" that should be avoided. $\endgroup$
    – Danielle
    Commented Jun 24, 2016 at 1:24

1 Answer 1

2
$\begingroup$

I guess the $m_{ij}$'s in your model are functions of a smaller number of parameters, and you then get into trouble when you evaluate the likelihood at some point in the parameterspace where some of these $m_{ij}$'s become numerically equal to zero? This is quite likely to happen near or at the MLEs. At such points in the parameter space, however, these observations have probability approaching 1 and so a contribution approaching $\ln(1)=0$ to the log-likelihood, so the way you handle this is in effect correct. An alternative general solution would be to always skip computing $\ln m_{ij}$ whenever you have observations $k_{ij}=0$ since $\ln m_{ij}$ is never needed for such observations.

Btw, I believe your expression $-m_{ij} + k_{ij}\ln(m_{ij}/k_{ij})$ is incorrect and should be $-m_{ij} + k_{ij}\ln m_{ij}$ (the log of the Poisson probability $e^{-m_{ij}}m_{ij}^{k_{ij}}/k_{ij}!$ omitting the constant term $-\ln k_{ij}!$)?

$\endgroup$
2
  • $\begingroup$ Yes, the m<sub>ij</sub> do depend on other parameters, and I was concerned about how this problem affects the estimation of those parameters. Your reply is consistent with whuber's comment to the OP as well. Thank you. Regarding the expression for the likelihood, you are correct about the full form as well; I am using a numerical approximation, and will edit the OP for clarity. $\endgroup$
    – Danielle
    Commented Jun 24, 2016 at 16:04
  • $\begingroup$ Danielle, that numerical approximation is good for largish $k$ (around $10$ or higher), but since you report having problems with values of $k$ near zero, it looks like a dangerous thing to rely on! Why not use the actual logarithm of the Gamma function? It's not difficult or time-consuming to compute. That alone might eliminate many of your numerical computation issues. $\endgroup$
    – whuber
    Commented Jun 24, 2016 at 16:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.