Error in optim : non-finite value supplied by optim

Samtschan
Level 1
Error in optim : non-finite value supplied by optim

Hi All, 

I am fitting a zero-inflated Poisson model using the R recipe. I am getting this error message below, can someone explain why is this and how can I fix it, please?

Error in optim(fn = loglikfun, gr = gradfun, par = c(start$count, start$zero, : non-finite value supplied by optim
Traceback:
 optim(fn = loglikfun, gr = gradfun, par = c(start$count, start$zero, 
 .     if (dist == "negbin") log(start$theta) else NULL), method = method, 
 .     hessian = hessian, control = control)  

 

0 Kudos
1 Reply
pmasiphelps
Dataiker

Hi,

This message pops up with a number of open source R packages. It typically means the algorithm's optimization function is unable to go further, perhaps due to multicollinearity issues, or lack of variance in the data.

There are more flexible packages out there, and you may want to try a zero-inflated negative binomial model, which removes the conditional target mean = variance assumption of the zero-inflated poisson model.

The glm package in R has this model: https://stat.ethz.ch/R-manual/R-devel/library/MASS/html/glm.nb.html

So does statsmodels in python: https://www.statsmodels.org/dev/generated/statsmodels.discrete.count_model.ZeroInflatedNegativeBinom...

Best,

Pat

0 Kudos