R_help Help
2009-Oct-27 00:21 UTC
[R] Poisson dpois value is too small for double precision thus corrupts loglikelihood
Hi - I have a likelihood function that involves sums of two possions: L = a*dpois(Xi,theta1)*dpois(Yi,theta2)+b*(1-c)*a*dpois(Xi,theta1+theta3)*dpois(Yi,theta2) where a,b,c,theta1,theta2,theta3 are parameters to be estimated. (Xi,Yi) are observations. However, Xi and Yi are usually big (> 20000). This causes dpois to returns 0 depending on values of theta1, theta2 and theta3. My first question is: is there anyway around this? My second question is regarding the likelihood function value. Since dpois returns 0, my log likelihood becomes infinite and causes problem when optimization. Is there any smart way to avoid this? Thank you, rc
Duncan Murdoch
2009-Oct-27 00:29 UTC
[R] Poisson dpois value is too small for double precision thus corrupts loglikelihood
On 26/10/2009 8:21 PM, R_help Help wrote:> Hi - I have a likelihood function that involves sums of two possions: > > L = a*dpois(Xi,theta1)*dpois(Yi,theta2)+b*(1-c)*a*dpois(Xi,theta1+theta3)*dpois(Yi,theta2) > > where a,b,c,theta1,theta2,theta3 are parameters to be estimated. > (Xi,Yi) are observations. However, Xi and Yi are usually big (> > 20000). This causes dpois to returns 0 depending on values of theta1, > theta2 and theta3. > > My first question is: is there anyway around this? > > My second question is regarding the likelihood function value. Since > dpois returns 0, my log likelihood becomes infinite and causes problem > when optimization. Is there any smart way to avoid this?If you use log=TRUE, you'll get the log density instead of the density, and you won't get underflow. Finding the sum of terms whose log you know but whose value you can't represent is just a little tricky, but you can do it using identities like log(A + B) = log(A) + log(1 + B/A) = log(A) + log(1 + exp(log(B) - log(A))) Duncan Murdoch
Apparently Analagous Threads
- Issues when trying to fit a nonlinear regression model
- Issues when trying to fit a nonlinear regression model
- Issues when trying to fit a nonlinear regression model
- Issues when trying to fit a nonlinear regression model
- Issues when trying to fit a nonlinear regression model