# Zero-inflated model: non-finite value supplied by optim

So I have the following model predicting the presence of an animal on a certain spot. As a time unit quarter is initially used, but for one of the species of animals there is some (little) interesting variation within the months. So instead of quarter (factor) I want to include month (factor) into the model as a time variable. But I get an error when I try to run the zero-inflated poisson (and negative binomial also) with the month instead of quarter.

The model with quarter as predictor looks like this:

cr_f1c = formula(cr ~ depth + habtype2 + quarter + hurseason + year + lightregime + depth*quarter + depth*hurseason + depth*year + depth*lightregime)
cr_zipf1c = zeroinfl(cr_f1c, dist = "poisson", link = "logit", data = allUVCdata)
summary(cr_zipf1c)

Call:
zeroinfl(formula = cr_f1c, data = allUVCdata, dist = "poisson", link = "logit")

Pearson residuals:
Min      1Q  Median      3Q     Max
-1.3485 -0.5650 -0.2814  0.1256 14.3362

Count model coefficients (poisson with log link):
Estimate Std. Error z value Pr(>|z|)
(Intercept)            -5.936049   2.484272  -2.389 0.016874 *
depth                   0.148349   0.088296   1.680 0.092932 .
habtype2Pinnacles       0.466881   0.154337   3.025 0.002486 **
habtype2Unexposed       0.514980   0.147179   3.499 0.000467 ***
quarter2                0.074480   0.206863   0.360 0.718814
quarter3                0.104256   0.263334   0.396 0.692174
quarter4                0.280803   0.223813   1.255 0.209611
hurseasonY              0.021838   0.176503   0.124 0.901533
year2013                1.596452   0.664552   2.402 0.016292 *
year2014                3.790261   0.556287   6.814 9.52e-12 ***
year2015                2.205248   0.559779   3.939 8.17e-05 ***
lightregimeLight        1.482895   2.405802   0.616 0.537642
depth:quarter2         -0.001569   0.004740  -0.331 0.740714
depth:quarter3         -0.002489   0.005999  -0.415 0.678266
depth:quarter4         -0.006888   0.005142  -1.340 0.180349
depth:hurseasonY        0.002535   0.003940   0.643 0.519987
depth:year2013         -0.049598   0.021527  -2.304 0.021222 *
depth:year2014         -0.115424   0.017704  -6.520 7.04e-11 ***
depth:year2015         -0.088689   0.017678  -5.017 5.25e-07 ***
depth:lightregimeLight -0.031523   0.086388  -0.365 0.715189

Zero-inflation model coefficients (binomial with logit link):
Estimate Std. Error z value Pr(>|z|)
(Intercept)              2.21642    4.16511   0.532 0.594629
depth                   -0.01364    0.16504  -0.083 0.934156
habtype2Pinnacles      -16.73199  485.47422  -0.034 0.972506
habtype2Unexposed       -1.29454    0.37891  -3.416 0.000634 ***
quarter2                 0.20681    1.57207   0.132 0.895337
quarter3                 1.29092    1.75101   0.737 0.460974
quarter4                 0.27225    1.55530   0.175 0.861041
hurseasonY              -0.92972    0.89675  -1.037 0.299846
year2013                 2.32961    1.84284   1.264 0.206179
year2014                 2.60298    1.66907   1.560 0.118869
year2015                 7.02916    3.29527   2.133 0.032916 *
lightregimeLight        -0.74676    3.46865  -0.215 0.829543
depth:quarter2          -0.02925    0.06352  -0.460 0.645160
depth:quarter3          -0.07610    0.07064  -1.077 0.281286
depth:quarter4          -0.04340    0.06337  -0.685 0.493377
depth:hurseasonY         0.01239    0.03503   0.354 0.723684
depth:year2013          -0.09100    0.07004  -1.299 0.193827
depth:year2014          -0.14156    0.06302  -2.246 0.024685 *
depth:year2015          -0.60836    0.22895  -2.657 0.007881 **
depth:lightregimeLight   0.07768    0.14075   0.552 0.580994
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Number of iterations in BFGS optimization: 132
Log-likelihood: -4007 on 40 Df


But when I run it with month as predictor, I get the following error:

cr_f1c = formula(cr ~ depth + habtype2 + month + hurseason + year + lightregime + depth*month + depth*hurseason + depth*year + depth*lightregime)
cr_zipf1c = zeroinfl(cr_f1c, dist = "poisson", link = "logit", data = allUVCdata)

Error in optim(fn = loglikfun, gr = gradfun, par = c(start$count, start$zero,  :
non-finite value supplied by optic


What does this tell me and how can I possibly include month in my model?

• I have the same problem as you, and I'm wondering if you have found a solution? Regards, C. – user178026 Sep 21 '17 at 9:39
• How many observations do you have? You're fitting a very complicated model so I'd expect you to have a lot of data to be able to estimated it. I would simplify the model initially; at the moment you are fitting a very complex model for both the Poisson and the zero-inflation parts of the model. Instead I would make the zero-inflation part much simpler (you'll need to specify the formula explicitly for the zero-inflation part) and see if you can fit that model with month, and then build up from there. – Gavin Simpson Dec 1 '17 at 20:04
• As well as supplying what @GavinSimpson suggests you could usefully explore the pattern of zeroes for habtype2 == Pinnacles – mdewey Dec 4 '17 at 15:49
• It may be that with month as a predictor (in combination with everything else) you can perfectly predict zeroes, which in a logistic regression leads to parameter estimates going to infinity unless checks are specifically put in to catch that. – jbowman Dec 8 '17 at 20:49