Brms model crashes when using specific variable

  • Operating System: Windows 10
  • brms Version: 2.7.0

Here’s a sample of the dataset I’m working with and the offending model:

structure(list(imm = c(2, 0, 0, 6, 3, 0, 42, 0, 0, 0), week = c(4, 
5, 2, 11, 11, 3, 7, 7, 10, 4), rep = structure(c(2L, 3L, 2L, 
2L, 3L, 2L, 2L, 1L, 1L, 2L), .Label = c("1", "2", "3"), class = "factor"), 
    trt = structure(c(2L, 1L, 4L, 5L, 4L, 5L, 5L, 1L, 1L, 3L), .Label = c("1", 
    "2", "3", "4", "5"), class = "factor"), bindenom = c(10, 
    8, 11, 8, 9, 9, 11, 11, 6, 10), nlive = c(6, 0, 3, 0, 0, 
    7, 6, 0, 0, 6), plantid = c(15, 21, 32, 49, 11, 49, 51, 36, 
    34, 4)), row.names = c(NA, -10L), class = c("tbl_df", "tbl", 
"data.frame")) -> hwf

priors <- set_prior("normal(0,5)", class = "b")

brm(bf(nlive|trials(bindenom) ~ trt + week + rep,
       zi ~ trt), data = hwf, family = zero_inflated_binomial(), chains = 1)

The model will run fine if I either omit the zi term OR if I add more variables to the predictor. Using trt alone, however, crashes the RStudio session.

On my windows 10 laptop with brms 2.8.0+, R 3.6, and the latest stable Rtools (3.5) it compiles and fits just fine. I don’t know what causes this problem on your machine but you may want to update brms, R, and/or Rtools.

1 Like

Updated R to 3.6 and brms to 2.8.0, no issues now. Thanks!

I have Windows 7, brms 2.9.0, R 3.6, and Rtools 3.5, and am experiencing the same problem as OP.

Reproducible example:

set.seed(2019)
(d <- data.frame(id = letters[1:20], logit = rnorm(20), y = NA, n = round(runif(20, min = 5, max = 20))))
(d$y <- round(plogis(d$logit) * d$n))
require(brms)
mix.b <- brm(y|trials(n) ~ (1|id), family = binomial("logit"), prior = prior(uniform(0,10), class = sd), data = d, iter = 11000)

Then, immediately after the model finishes compiling and the sampling is due to begin, the R session always crashes.

I use brms development, i.e.,

if (!requireNamespace("devtools")) {
  install.packages("devtools")
}
devtools::install_github("paul-buerkner/brms")

and R 3.6.0, with latest RStudio on OS X. Works for me:

> summary(mix.b)
 Family: binomial 
  Links: mu = logit 
Formula: y | trials(n) ~ (1 | id) 
   Data: d (Number of observations: 20) 
Samples: 4 chains, each with iter = 11000; warmup = 5500; thin = 1;
         total post-warmup samples = 22000

Group-Level Effects: 
~id (Number of levels: 20) 
              Estimate Est.Error l-95% CI u-95% CI Eff.Sample Rhat
sd(Intercept)     0.90      0.26     0.47     1.48       7497 1.00

Population-Level Effects: 
          Estimate Est.Error l-95% CI u-95% CI Eff.Sample Rhat
Intercept    -0.22      0.25    -0.73     0.28       7749 1.00

Samples were drawn using sampling(NUTS). For each parameter, Eff.Sample 
is a crude measure of effective sample size, and Rhat is the potential 
scale reduction factor on split chains (at convergence, Rhat = 1).

I’m still experiencing the same crash at the same point after executing that code chunk. I suppose it must be a problem with the Windows version of brms, then.

Then I’m sure @paul.buerkner is interested in hearing about it.

torkar: Yes. I figured it would be better to post on this already-existing thread, but I now see that this thread has already been marked as Resolved, which doesn’t accurately reflect the status of my problem. With this in mind and given the apparent irreversibility of the resolved-status, would it be more appropriate if I started a new thread?

I think so. and it is likely a Stan problem so you may want to also show the Stan code of your model.