# Error: logml needs to be numeric

**URL:** https://discourse.mc-stan.org/t/error-logml-needs-to-be-numeric/13554
**Category:** brms
**Created:** [March 6, 2020, 7:28am UTC](https://discourse.mc-stan.org/t/error-logml-needs-to-be-numeric/13554 "2020-03-06T07:28:19Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![PiscisBailey](https://avatars.discourse-cdn.com/v4/letter/p/839c29/32.png) [@PiscisBailey](https://discourse.mc-stan.org/u/PiscisBailey)
#### Post date: [March 6, 2020, 7:28am UTC](https://discourse.mc-stan.org/t/error-logml-needs-to-be-numeric/13554/1 "2020-03-06T07:28:19Z")

</div>

- Operating System: Windows 10
- brms Version: 2.5.0
- R Version: 3.5.2
- RStudio Version: 1.2.5033

I am successfully fitting logistic regressions with a random effect - e.g.,

cop0 \<- brm(g\_samp ~ s\_legg\_add + (1 + s\_legg\_add|site), data = p\_cop,  
family = bernoulli(“logit”),  
prior = c(set\_prior(“normal(0,10)”, class = “b”, coef = “s\_legg\_add”)),  
warmup = 1000, iter = 2000, chains = 4,  
control = list(adapt\_delta = 0.99, max\_treedepth = 10), save\_all\_pars = TRUE )

But, as soon as I try to run a hurdle model - e.g.,

cop.o0 \<- brm(bf(no\_eggs ~ s\_legg\_add + (1 + s\_legg\_add|site) + offset(log(mass)),  
hu ~ s\_legg\_add + s\_lmass + (1 |site)),  
data = p\_cop, family = hurdle\_negbinomial(),  
prior = c(set\_prior(“normal(0,10)”, class = “b”, coef = “s\_legg\_add”),  
set\_prior(“gamma(0.01,0.01)”, class = “shape”),  
set\_prior(“normal(0,10)”, class = “b”, coef = “s\_legg\_add”, dpar=“hu”),  
set\_prior(“normal(0,10)”, class = “b”, coef = “s\_lmass”, dpar=“hu”)),  
warmup = 1000, iter = 2000, chains = 4,  
control = list(adapt\_delta = 0.99, max\_treedepth = 10), save\_all\_pars = TRUE)

I am hit with the following message:

Error: logml values need to be numeric

This is completely baffling given that these hurdle models were working earlier today. I have tried updating R and Stan and brms but I found that this actually lead to a series of other problems with compiling models, so I have gone back to the previous version of R that was working with Stan and brms. I have also started a new Rproject and moved everything in to it, but that has not solved the problem. Currently, I can get the first model to run without an issue, but the second model errors out immediately.

---

<div class="post-metadata">

### Author: ![paul.buerkner](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/paul.buerkner/32/3303_2.png) [@paul.buerkner](https://discourse.mc-stan.org/u/paul.buerkner)
#### Post date: [March 6, 2020, 12:12pm UTC](https://discourse.mc-stan.org/t/error-logml-needs-to-be-numeric/13554/2 "2020-03-06T12:12:36Z")

</div>

Can you provide a minimal reproducible example for the error?

---

<div class="post-metadata">

### Author: ![PiscisBailey](https://avatars.discourse-cdn.com/v4/letter/p/839c29/32.png) [@PiscisBailey](https://discourse.mc-stan.org/u/PiscisBailey)
#### Post date: [March 6, 2020, 5:50pm UTC](https://discourse.mc-stan.org/t/error-logml-needs-to-be-numeric/13554/3 "2020-03-06T17:50:20Z")

</div>

Hi, thanks for responding! I have attached a .csv for the data and pasted my r-code below…

[p\_cop\_ex.csv](https://discourse.mc-stan.org/uploads/short-url/6smAc8TQghynwvXpzi4yrXGXx6a.csv) (21.5 KB)

```
knitr::opts_chunk$set(echo = TRUE)

library(ggplot2)
library(dplyr)
library(tidyr)
library(stringi)
library(rstan)
library(shinystan)
library(brms)
library(bayesplot)
library(devtools)
library(pkgbuild)
library(bridgesampling)

pkgbuild::has_build_tools(debug = TRUE)

rstan_options(auto_write=T)

options(mc.cores = parallel::detectCores())

(auto_write = TRUE)

p_cop_ex <- read.csv("p_cop_ex.csv")

#model that works:

cop0 <- brm(g_samp ~ s_legg_add + (1 + s_legg_add|site), data = p_cop_ex,
          family = bernoulli("logit"),
          prior = c(set_prior("normal(0,10)", class = "b", coef = "s_legg_add")),
          warmup = 1000, iter = 2000, chains = 4,
          control = list(adapt_delta = 0.99, max_treedepth = 10), save_all_pars = TRUE )

#model that doesn't work:

cop.o0 <- brm(bf(no_eggs ~ s_legg_add + (1 + s_legg_add|site) + offset(log(mass)),
           hu ~ s_legg_add + s_lmass + (1 |site)),
           data = p_cop_ex, family = hurdle_negbinomial(),
           prior = c(set_prior("normal(0,10)", class = "b", coef = "s_legg_add"),
                     set_prior("gamma(0.01,0.01)", class = "shape"),
                     set_prior("normal(0,10)", class = "b", coef = "s_legg_add", dpar="hu"),
                     set_prior("normal(0,10)", class = "b", coef = "s_lmass", dpar="hu")),
           warmup = 1000, iter = 2000, chains = 4,
           control = list(adapt_delta = 0.99, max_treedepth = 10), save_all_pars = TRUE)

```

---

<div class="post-metadata">

### Author: ![paul.buerkner](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/paul.buerkner/32/3303_2.png) [@paul.buerkner](https://discourse.mc-stan.org/u/paul.buerkner)
#### Post date: [March 8, 2020, 11:39am UTC](https://discourse.mc-stan.org/t/error-logml-needs-to-be-numeric/13554/4 "2020-03-08T11:39:29Z")

</div>

You loaded **bridgesampling** after **brms** , with the former masking the bf function of the latter. Avoid loading bridgesampling or loading it before brms will solve this problem.

---

<div class="post-metadata">

### Author: ![PiscisBailey](https://avatars.discourse-cdn.com/v4/letter/p/839c29/32.png) [@PiscisBailey](https://discourse.mc-stan.org/u/PiscisBailey)
#### Post date: [March 9, 2020, 6:09am UTC](https://discourse.mc-stan.org/t/error-logml-needs-to-be-numeric/13554/5 "2020-03-09T06:09:16Z")

</div>

Thanks! Everything is working now.
