Skip to content
Prev 17999 / 20628 Next

glmmTMB negbinom not working with spatial autocorrelation

Did you really try to fit a model with

+ ziformula = ~.

in the formula? Or do you mean that you fitted a zero-inflated negative
binomial (i.e.

  y ~ ....,  ziformula=~., family=nbinom1, ... ) ?

 This is surprising behaviour.

 * Does it work in a clean R session?
 * Does your model work with any alternative families (e.g. nbinom2) or
simplifications (e.g. leave out the zero-inflation, or make ziformula =
~1 ) ?
 * Can you post a minimal reproducible example? The code below works
(sort of -- convergence problems with the second model, but these are
related to the data and don't sound like what you described).


===
set.seed(101)
library(glmmTMB)
library(lme4)
n <- 400
dd <- expand.grid(population=letters[1:20],
                  species=LETTERS[1:10],
                  rep=seq(n/(10*20)))
dd <- transform(dd,
                b1=rnorm(n),
                b2=rnorm(n),
                x=rnorm(n),
                y=rnorm(n))
dd$eta <- simulate(~poly(b1,2)+poly(b2,2)+
                       (1|population/species),
                   family=gaussian,
                   newdata=dd,
                   newparam=list(beta=rep(1,5),
                                 theta=rep(1,2),
                                 sigma=1))[[1]]
dd$resp <- rnbinom(n, mu=exp(dd$eta), size=1)
dd <- transform(dd,
                pos=numFactor(x,y),
                group=factor(1))
model1 <- glmmTMB(resp ~ poly(b1,2) + poly(b2,2) + exp(pos + 0|group ) +
            (1|population/species), data = dd,
        family=poisson,
        verbose=TRUE)

model2 <- update(model1, family=nbinom1)
On 2019-10-16 1:33 p.m., Bansal, Udita wrote: