Brms Causing R Session Aborted (R Encountered Fatal Error) Only With Control Parameters Included

I have been attempting to run a zero-inflated poisson model with the attached data and following code:

Example.csv (21.5 KB)

example<-read.csv(“Example.csv”,header=T)
as.factor(example$ID)->example$ID
as.factor(example$Sex)->example$Sex
as.factor(example$Level)->example$Level
as.factor(example$LesionType)->example$LesionType

formula<-bf(LesionNumber ~ Level + LesionType + Level:LesionType + Sex + AgeDeath + DD + PMI + (1 | ID), zi ~ Level + LesionType + Level:LesionType + Sex + AgeDeath + DD + PMI + (1 | ID))

model<-brm(formula=formula, data=example, family=“zero_inflated_poisson”,warmup=2000,iter=4000,seed=34)

I then received errors about treedepth, Rhat, bulk ESS, and tail ESS. Therefore, I tried to adjust the code with the following:

model.updated<-brm(formula=formula, data=lesion_number_total_staged, family=“zero_inflated_poisson”,warmup=4000,iter=8000,seed=34,control=list(max_treedepth=15))

However, I then get an R Session Aborted error. I’ve never encountered this with recent models and have narrowed down that it only happens when inputting control parameters. Any insight on why this is happening? I’ve tried uninstalling brms, rstan, and rstantools and reinstalling but that didn’t seem to help.

I’m using a MacBook Pro with 16GB memory on Mojave Version 10.14.6 and RStudio version Version 1.4.1717.

1 Like

I ran into a similar issue the other week with adapt_delta (see here). After a lot of fooling around, the quick fix was to install the developmental version of brms from GitHub.

remotes::install_github("paul-buerkner/brms")
2 Likes

Sorry, did not work for me. Same problem when including the adapt_delta control. Any more thoughts?

That’s frustrating. Sadly, that’s all I’ve got on this one.

Thanks anyway, Solomon! Much appreciated. I try rstanarm now, however, I liked the possibility for multivariate responses in brms. All the best from Norway, Ulrich

1 Like

I just updated to R 4.1.2 on an Intel Mac with Big Sur 11.6 and experienced the same issue. Specifying a model with adapt_delta caused R Studio to crash. I tried uninstalling rstan and brms to no avail but Solomon’s solution appears to have worked.

1 Like

Other users have reported that upgrading to the preview of the next RStan version has solved this problem for them:

remove.packages(c("StanHeaders", "rstan"))
install.packages("StanHeaders", repos = c("https://mc-stan.org/r-packages/", getOption("repos")))
install.packages("rstan", repos = c("https://mc-stan.org/r-packages/", getOption("repos")))
2 Likes

Unfortunately @Solomon’s package re-installation didn’t work for me. The R session doesn’t abort but a segfault is created. Using control = list(adapt_delta = 0.95). Last chain completes (this happened to be chain 3 this time) and then segfaults reported for all 4 chains. Strangely the brmsfit object saves correctly (phew!), which may indicate at what point the segfault occurs.

Chain 3: Iteration: 100000 / 100000 [100%]  (Sampling)
Chain 3: 
Chain 3:  Elapsed Time: 753.436 seconds (Warm-up)
Chain 3:                10048.5 seconds (Sampling)
Chain 3:                10801.9 seconds (Total)
Chain 3: 

 *** caught segfault ***
address 0x18, cause 'memory not mapped'
An irrecoverable exception occurred. R is aborting now ...

 *** caught segfault ***
address 0x18, cause 'memory not mapped'
An irrecoverable exception occurred. R is aborting now ...

 *** caught segfault ***
address 0x18, cause 'memory not mapped'
An irrecoverable exception occurred. R is aborting now ...

 *** caught segfault ***
address 0x18, cause 'memory not mapped'
An irrecoverable exception occurred. R is aborting now ...
Warning messages:
1: There were 379858 divergent transitions after warmup. See
https://mc-stan.org/misc/warnings.html#divergent-transitions-after-warmup
to find out why this is a problem and how to eliminate them. 
2: Examine the pairs() plot to diagnose sampling problems 

R version 4.2.1
Linux Mint 20.3