Reputation: 1
I'm modeling camera trap data (counts) with camera site as a random effect and landscape-level covariates + season as fixed effects, and an offset for number of days the camera station was active, as below:
mod2 <- glmmTMB(Coyote ~ develop + PERCENTILE + season + (1|site),
offset = log(days.active),
data = all_dat, family = "nbinom2")
and am, as of today, encountering the following error message:
Error in fitTMB(TMBStruc) : negative log-likelihood is NaN at starting parameter values
I have about 400 observations in my data. I only get this error when the offset is included, and it happens with both a negative binomial and Poisson model. My code was working just fine until it suddenly didn't, so I assume the issue was related to the recent Matrix changes and associated dependencies in TMB, as detailed in similar questions here with the same error in glmmTMB and here with a similar issue in lme4. However, none of the solutions in the links have worked for me (I tried commenting instead of opening a new question but wasn't able to as my account is new). I'm on macOS 12.5.
I have tried:
Both reinstallation methods didn't work at all for me until I installed gfortran, but now they are at least installing -- just not solving my issue.
Thanks in advance for any help!
Upvotes: 0
Views: 1531
Reputation: 226742
This is just a guess, but I can easily get this error if I have a 0 in the variable that I am logging in order to get the offset (which would be any(all_dat$days.active == 0)
in your case):
library(glmmTMB)
data("sleepstudy", package = "lme4")
ss <- transform(sleepstudy, offset = c(0, rep(1, nrow(sleepstudy)-1)))
m1 <- glmmTMB(round(Reaction)~ Days, family = nbinom2, data = ss) ## works fine
m2 <- update(m1, offset = log(offset))
Error in fitTMB(TMBStruc) : negative log-likelihood is NaN at starting parameter values
(However, this is not consistent with "it was working before but then it stopped working", as this error should have happened with previous versions of the package too ...)
Upvotes: 0