[R-sig-ME] Trouble looping model using glmmTMB

Viraj Torsekar viraj.torsekar at gmail.com
Sun Apr 8 16:27:53 CEST 2018

Hello all,

I'm trying to find out if distance moved by crickets is a function of
predation risk. My response variable is 'distance moved' and the predictor
is probability of spatial proximity with predator, ranging from 0 to 1. The
response variable is zero-inflated (about 77% values are zeroes) and its
variance is far higher than its mean. Hence, I tried running zero-inflated
negative binomial mixed models using glmmADMB, which failed (mixed because
I have multiple values per individual). Following was the error I kept
encountering: "function maximizer failed" (attaching a text file with
details of this model by keeping debug=TRUE).

Hence, I shifted to glmmTMB (version: 0.2.0), on Dr. Bolker's advice, and
it worked! But the problem is, when I try bootstrapping the model using to
obtain confidence intervals, I keep getting the following error after
varying number of runs: 'Error in optimHess(par.fixed, obj$fn, obj$gr):
gradient in optim evaluated to length 1 not 5'. This non-parametric
bootstrapping routine involves for loops in which the model is run using
bootstrapped groups (belonging to the grouping variable; individual.id in
my case) and the model coefficients thus obtained constitute the confidence
intervals. I've tried running 10,000 iterations, but the error pops up
within 10 to 100 runs.

Does anyone have suggestions regarding what can be changed?

Details of the model run singly and not in the loop:

 Family: nbinom2  ( log )
Formula:          movement.whole ~ poc + (1 | female.id)
Zero inflation:                  ~1
Data: incrisk_females_comm

     AIC      BIC   logLik deviance df.resid
  1725.1   1745.9   -857.5   1715.1      474

Random effects:

Conditional model:
 Groups    Name        Variance Std.Dev.
 female.id (Intercept) 0.07924  0.2815
Number of obs: 479, groups:  female.id, 110

Overdispersion parameter for nbinom2 family (): 1.59

Conditional model:
            Estimate Std. Error z value Pr(>|z|)
(Intercept)  4.66384    0.14161   32.93   <2e-16 ***
poc         -0.08815    0.20978   -0.42    0.674
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Zero-inflation model:
            Estimate Std. Error z value Pr(>|z|)
(Intercept)   1.2442     0.1098   11.34   <2e-16 ***

Please do mention if you need further details. Thank you in advance.

Viraj Torsekar,
PhD Candidate,
Centre for Ecological Sciences,
Indian Institute of Science

	[[alternative HTML version deleted]]

More information about the R-sig-mixed-models mailing list