[R-sig-ME] Error from glmmTMB().

Ben Bolker bbo|ker @end|ng |rom gm@||@com
Thu Mar 19 03:24:15 CET 2020


  I did a little more poking around with this.

  It works (i.e. fits with no warnings with binomial() instead of
betabinomial().

  It works, sort of (i.e. gives 1 warning about NaN evaluation and a
non-pos-def Hessian warning, probably from an effectively singular
model, but gives sensible fixed-effect estimates and std devs) with
link=logit instead of cloglog.

   Debugging my way through glmmTMB:::fitTMB(), even the first
evaluation of the objective function gives NaN, and the gradient is a
vector of NaN values.  I suspect we have a failure to clamp the cloglog
function somewhere, and may know how to fix it.

  This is a very nice, simple example that may help us improve a bunch
of stuff (it will also help us put some tests in useful places to get
*slightly* less opaque error messages).

  I know this doesn't solve your problem immediately - but if I'm lucky
and have a bit of time I may be able to implement something soon.

  thanks Rolf!

  Ben

On 2020-03-17 9:50 a.m., Mollie Brooks wrote:
> It may be an overparameterization issue because I was able to get simpler models to work. We could make the error message clearer, but tried to document it at the bottom of the troubleshooting vignette. The general advice in that case is to (1) try rescaling predictor variables, (2) try a simpler model and build up, and (3) try different starting values, possibly based on a simpler model. 
> 
> I tried scaling Dose that that didn’t help. 
> 
> To get the right shape for starting values, you could check the structures in the unfitted model
> 
> mod  <- glmmTMB(fmla, data = X, family = betabinomial(link = "cloglog"),
>               dispformula = ~1, doFit=FALSE)
> 
> dimnames(mod$data.tmb$X)[[2]]
> 
> dimnames(mod$data.tmb$Z)[[2]]
> 
> str(mod$parameters)
> 
> start <- list(beta=rep(0.1, 12), b=rep(.01, 12)) #fill in better values based on your best guess
> 
> fit3  <- glmmTMB(cbind(Dead, Alive) ~ Trt+0 +Dose + (1 | Rep), data = X, family = betabinomial(link = "cloglog"))
> 
> 
> start <- list(beta = c(fixef(fit3)[[1]][1:6], rep(.1, 6)),
> 	b=c(unlist(ranef(fit3)[[1]]$Rep), rep(.1, 6)))
> 	
> fit  <- glmmTMB(fmla, data = X, family = betabinomial(link = "cloglog"), start=start)
> 
> That was my best attempt at getting it to run, but it doesn’t work. 
> 
> If you think this is a bug, you could add it to the issue tracker on GitHub.
> 
> cheers,
> Mollie
> 
>> On 15Mar 2020, at 4:32, Rolf Turner <r.turner using auckland.ac.nz> wrote:
>>
>>
>> I am getting an error, that I have no idea what to do about, from glmmTMB():
>>
>> library(glmmTMB)
>> fmla <- cbind(Dead, Alive) ~ (Trt + 0)/Dose + (Dose | Rep)
>> X    <- dget("X.txt")
>> fit  <- glmmTMB(fmla, data = X, family = betabinomial(link = "cloglog"),
>>               dispformula = ~1)
>>
>>> Error in optimHess(par.fixed, obj$fn, obj$gr) :   gradient in optim evaluated to length 1 not 16
>>> In addition: There were 16 warnings (use warnings() to see them)
>>
>> The warnings are all repetitions of
>>
>>> 1: In nlminb(start = par, objective = fn, gradient = gr,  ... :
>>>  NA/NaN function evaluation
>>
>> The error sounds to me like something is amiss in the code.
>>
>> Can anyone confirm/deny/suggest what I might do to get this call to glmmTMB() to run?
>>
>> Thanks.
>>
>> cheers,
>>
>> Rolf Turner
>>
>> P.S.  The data set is attached.
>>
>> -- 
>> Honorary Research Fellow
>> Department of Statistics
>> University of Auckland
>> Phone: +64-9-373-7599 ext. 88276
>> <X.txt>_______________________________________________
>> R-sig-mixed-models using r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
> 
> 
> 	[[alternative HTML version deleted]]
> 
> _______________________________________________
> R-sig-mixed-models using r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
>



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