2

It seems a bit silly to post this as a question, but I haven't been able to find an answer for this. I want to use the glmmTMB package for modelling data with zero-inflation, but when I try to fit the model I want, the function glmmTMB() returns the following error:

Error in glmmTMB(y ~ x + (1 | z), data = df, ziformula = x) : object 'x' not found

This only happens after I introduce the term for ziformula. The model without that term works just fine. For some reason, it seems that the ziformula overrides the data command in the function.

My glmmTMB package version is 1.1.3 and my R version is 4.1.1.

Here's a little sample data to reproduce the problem:

df <- data.frame(y=c(2,2,5,7,3,8,3,2,4,6),
                    x = c(23,21.7,22.5,18,20,19.9,21,20.3,20,20.5),
                    z = c(rep("a",5),rep("b",5)))
glmmTMB(y ~ x + (1|z), data = df, ziformula = x)

If anyone has had any similar issue, I would be grateful for any tips on how to solve it!

lovalery
  • 4,524
  • 3
  • 14
  • 28
LaHN
  • 47
  • 7
  • Have you tried `ziformula = df$x`? – SamR Mar 15 '22 at 14:46
  • @SamR, I have but that gives the following error `Error in terms.formula(formula, data = data) : invalid model formula in ExtractVars` – LaHN Mar 15 '22 at 14:52
  • 3
    `ziformula` should be a formula with a tilde `~`. See the documentation. – Vincent Mar 15 '22 at 15:49
  • 1
    @Vincent that did the trick, thank you so much! For some reason I missed that while reading on the topic. – LaHN Mar 16 '22 at 06:40

0 Answers0