glmmtmbglmm

glmmTMB model "Error in fitTMB(TMBStruc)" - why am I getting this?


I'm running a glmm of pathogens in edible crabs with a pathogen as my dependent variable and I have sex, width, external disease, season, damage and biofouling as explanatory variables and site as a random effect. The code for the model looks like this:

glmmTMB(Paramikrocytos ~ Width + Sex + Condition + Disease + Biofouling + (1 | Site),
                         data = crab, family = "binomial")

When I run this I get the following error message:

Error in fitTMB(TMBStruc) : 
  negative log-likelihood is NaN at starting parameter values

If I try using a Poisson family instead of a binomial like the troubleshooter suggests I get the same error message and the output looks like this:

Conditional model:
              Estimate Std. Error z value Pr(>|z|)
(Intercept) -3.182e+00        NaN     NaN      NaN
Width        5.834e-03        NaN     NaN      NaN
SexM        -2.001e-01        NaN     NaN      NaN
Condition2  -4.017e-01        NaN     NaN      NaN
Condition3  -3.297e+01        NaN     NaN      NaN
Condition4  -6.188e-01        NaN     NaN      NaN
Condition5  -1.037e+02        NaN     NaN      NaN
Condition7  -2.773e-01        NaN     NaN      NaN
Disease2     4.384e-01        NaN     NaN      NaN
Disease3     2.375e-01        NaN     NaN      NaN
Disease4     2.486e+00        NaN     NaN      NaN
Disease5     5.011e+01        NaN     NaN      NaN
Disease6    -1.242e+01        NaN     NaN      NaN
Biofouling2  2.794e-01        NaN     NaN      NaN
Biofouling3 -4.770e+01        NaN     NaN      NaN
Biofouling4 -8.677e+01        NaN     NaN      NaN

I tried using a Poisson family as was suggested when I ran the function "diagnose" on the model but I got the same error message. Is there a way of running a negative binomial in this? What could possibly be causing this error message?


Solution

  • I've solved it! I needed to set the priors using

    cprior <- data.frame(prior = rep("normal(0,3)", 2),
                         class = rep("beta", 2),
                         coef = c("(Intercept)", ""))
    

    If I add priors = cprior into the model then it works!

    If anyone else is having this issue, try this and see if it helps.