[R-sig-ME] glmmTMB negbinom not working with spatial autocorrelation
Ben Bolker
bbo|ker @end|ng |rom gm@||@com
Thu Oct 17 03:20:37 CEST 2019
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:
> Hello all,
>
> I had been running a mixed model with poisson distribution of the following type, with a spatial autocorrelation term, which works fine:
>
> Y(count data) ~ x1 + square(x1) + x2 + square(x2) + exp( ) + (1|population/species)
>
> I realized that my dataset has a lot of small values (mostly 1 and 2) and some large values, so that the data is highly skewed and over dispersed. So I tried to run the following negbinom1 model:
>
> Y(count data) ~ x1 + square(x1) + x2 + square(x2) + exp( ) + (1|population/species) + ziformula = ~.
>
> This time the model doesn’t run and says it cannot find one of the independent variables in the dataset. If I remove that variable from the model then it says so for another variable and so on. If I remove the factor for spatial autocorrelation, the model seems to work fine. Can anyone tell me what’s happening and if what I am doing is appropriate for a highly skewed and over dispersed dataset?
>
> Thank you
> Udita Bansal
> Project Assistant
> Centre for Ecological Sciences
> Indian Institute of Science
> India
>
>
> [[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