Errors; Hurdle model in brms

I would like to hurdle model for fish catch with brms packages.

ff <- read.csv(file.choose())
ff <- merge(f, n[,1:7], by = "code", all.x = TRUE) %>%
  filter(!is.na(sigma.BTM_rcp26_2005.5YS) & !is.na(sigma.S100_rcp26_2005.5Y.1) & !is.na(to.BTM_rcp26_2005.5YAVE.) & !is.na(to.S100_rcp26_2005.5YAVE))

ff.csv (66.5 KB)

fbmodel <- brm(total_2005 ~ Thickness.average + Depth.range + Depth.average + 
                                sigma.BTM_rcp26_2005.5YS + sigma.S100_rcp26_2005.5Y.1 +
                                to.BTM_rcp26_2005.5YAVE. + to.S100_rcp26_2005.5YAVE, 
                                offset(totalnet_2005) , 
                   data      = ff,
                   family    = hurdle_negbinomial(link = "log", link_shape = "log", link_hu = "logit"),
                   prior   = c(set_prior("normal(0,10)", class = "b")),
                   warmup    = 300,
                   iter      = 1000,
                   chains    = 4,
                   save_all_pars = TRUE,
                   backend = "cmdstanr",
                   control = list(adapt_delta = 0.99, max_treedepth = 15),
                   save_model = "fish_stanscript",
                   file = "fish")

but it returned the error;

 Chain 4 Rejecting initial value:
    Chain 4   Log probability evaluates to log(0), i.e. negative infinity.
    Chain 4   Stan can't start sampling from this initial value.
    Chain 4 Initialization between (-2, 2) failed after 100 attempts. 
    Chain 4  Try specifying initial values, reducing ranges of constrained values, or reparameterizing the model.

hurdle_negbionomial was not suitable for this data?

@marie_stan looks like a reasonable selection based on the data. Did you try making a simpler version of this model first (say with fewer predictors or some simulated data)? Also it looks like you don’t have any predictors of the hurdle component?

Thank you very much for the comment.

I changed into a simple setting (one variable considered) and added “hu ~” components.
It successfully seemed to work, but increasing any variables, again the same error came up.

fbmodel <- brm(bf(total_2005 ~ Depth.average,
                  hu ~ Depth.average),   # give 1 instead, it works
                   data      = ff,
                   family    = hurdle_negbinomial(link = "log", link_shape = "log", link_hu = "logit"),
                   prior   = c(set_prior("normal(0,10)", class = "b")),
                   warmup    = 500,
                   iter      = 1000,
                   chains    = 4,
                   save_all_pars = TRUE,
                   backend = "cmdstanr",
                   control = list(adapt_delta = 0.99, max_treedepth = 15),
                   save_model = "fish_stanscript",
                   file = "fish")

Thanks,

I fount it successfully worked.

fbmodel <- brm(bf(total_2005 ~ 
                   Thickness.average + Depth.range + 
                    Depth.average +
                    sigma.BTM_rcp26_2005.5YS + sigma.S100_rcp26_2005.5Y.1 +
                    to.BTM_rcp26_2005.5YAVE. + to.S100_rcp26_2005.5YAVE + 
                    offset(log(totalnet_2005)), 
                  hu ~
                    Thickness.average + Depth.range + 
                    Depth.average + 
                    sigma.BTM_rcp26_2005.5YS + sigma.S100_rcp26_2005.5Y.1 +
                    to.BTM_rcp26_2005.5YAVE. + to.S100_rcp26_2005.5YAVE ),  
                   data      = ff,
                   family    = hurdle_negbinomial(link = "log", link_shape = "log", link_hu = "logit"),
                   prior   = c(set_prior("normal(0,10)", class = "b")),
                   warmup    = 500,
                   iter      = 1000,
                   chains    = 4,
                   cores     = 4,
                   inits = 0, 
                   save_all_pars = TRUE,
                   backend = "cmdstanr",
                   control = list(adapt_delta = 0.99, max_treedepth = 15),
                   save_model = "fish_stanscript",
                   file = "fish")

Great, is it the offset(log(totalnet_2005)) that resolved the error? That variable has a lot of zeros in the data. Wouldn’t that cause those rows to be dropped?