Reputation: 345
I am trying to run a simple poisson model of zero inflated with zeroinfl library. Getting a strange error anyway I try it. Any thoughts?
mdl2 <- mtcars %>% zeroinfl(formula = "mpg ~ cyl")
Error in formula[[3]] : subscript out of bounds
mdl2 <- mtcars %>% zeroinfl(formula = "mpg ~ cyl | cyl")
Error in formula[[3]] : subscript out of bounds
Upvotes: 0
Views: 258
Reputation: 3134
This is because of the quotes, you are giving a character string and not a formula.
> class("mpg ~ cyl")
[1] "character"
> class(mpg ~ cyl)
[1] "formula"
> mtcars %>% pscl::zeroinfl(formula = vs ~ cyl)
# works
If you need to build a formula from a set of strings, you can call as.formula("vs ~ cyl")
.
Upvotes: 1