I want to maximize the logrithm of \begin{align*} L(\theta) = f(X|\theta) = \int \prod_{i=1}^n f(x_i|y,\theta)g(y)\,dy, \end{align*} where $X = (x_1,\cdots,x_n)$ and $y$ is missing data. The issue is that, in the model I am working on, $$\prod_{i=1}^n f(x_i|y,\theta)$$ becomes zero on computer program (Matlab/Python) as $0<f(x_i|y,\theta)<1$ for all $i$ and $y$. Is there any method to deal with this issue?
-
$\begingroup$ Why do x and y have the same index in the likelihood? $\endgroup$– user289381Commented Jul 9, 2020 at 23:43
-
$\begingroup$ @ping Sorry my bad. I fixed it. $\endgroup$– user1292919Commented Jul 10, 2020 at 0:37
-
$\begingroup$ So, there's a single, global $y$, not an individual $y_i$ for each $x_i$ (as there would be in latent variable models)? $\endgroup$– user20160Commented Jul 10, 2020 at 1:00
-
$\begingroup$ @user20160 yes there is a single $y$. $\endgroup$– user1292919Commented Jul 10, 2020 at 2:14
1 Answer
You can factor out powers of 2 or 10 and count them up separately. That is, instead of
$$L(\theta)=\int\prod_{i=1}^n f(x_i|y,\theta)g(y)\,dy$$ work with, say, $$L(\theta)=10^{-an}\int\prod_{i=1}^n 10^af(x_i|y,\theta)g(y)\,dy$$ where the exponent is chosen to keep $f(x_i|y,\theta)$ a reasonable size. Then $$\log L(\theta)=-2n\log 10 +\log \int\prod_{i=1}^n 10^2f(x_i|y,\theta)g(y)\,dy$$ and you could even forget the first term, since it doesn't depend on $\theta$.