Hi Everyone,
I’m having problems to fit Zero Inflated Poisson (ZIP) and Zero Inflated Negative Binomial (ZIBN) models using the brms package.
For example:
ZIP.noCAR.prior = c((prior(normal(0,1000),class = b)),
(prior(normal(0,1000),class = Intercept)))
ZIP.ind <- brm(brm(formula = Fevereiro ~ PIB_1000 +
offset(log(Pop)),zi ~ TOTAL),
data = saopaulodf,
prior = ZIP.noCAR.prior,
family = zero_inflated_poisson(),
iter = 50000,
warmup = 10000,
thin = 50,
chains = 1,
init = 0,
control = list(max_treedepth=12))
And this is the error message I got :
Error: Argument 'data' must be coercible to a data.frame.
But,
> class(saopaulodf)
[1] "data.frame"
And when I use a CAR component like this code below:
ZIP.prior = c((prior(normal(0,1000),class = b)),
(prior(normal(0,1000),class = Intercept)),
(prior(uniform(0, 1000),class= sdcar)),
(prior(beta(1, 1),class= rhocar))
)
ZIP <- brm(bf(brm(formula = Fevereiro ~ PIB_1000 +
offset(log(Pop)) + car(W,type = "bym2")),zi ~ TOTAL),
data = saopaulodf,
data2 = list(W = W),
prior = ZIP.prior,
family = zero_inflated_poisson(),
iter = 50000,
warmup = 10000,
thin = 50,
chains = 1,
init = 0,
control = list(max_treedepth=12))
I got this error message:
Error: Object 'W' was not found in 'data2'.
But when I make a Poisson model using the same objects I can fit the model with no problems. For example:
poi.prior = c((prior(normal(0,1000),class = b)),
(prior(normal(0,1000),class = Intercept)),
(prior(gamma(1, 1),class= sdcar)),
(prior(beta(1, 1),class= rhocar))
)
poi <- brm(formula = Fevereiro ~ PIB_1000 +
car(W,type = "bym2"),
data = saopaulodf,
data2 = list(W = W),
prior = poi.prior,
family = poisson(),
iter = 50000,
warmup = 10000,
thin = 50,
chains = 1,
init = 0,
control = list(max_treedepth=12))
Can anyone help me with this issue ?
- Operating System: Windows 11; R 4.4.1
- brms Version:2.22.0