Fata error with brms upon simulation start: 'R Session Aborted R encountered a fata error. The session was terminated.'

Running bms causes a Fatal Error write when the simulation starts:

‘R Session Aborted R encountered a fata error. The session was terminated.’

Error occurs when sampling starts

Compiling Stan program...
Start sampling

SAMPLING FOR MODEL 'c86a9091f1b21a9940887ec8be562538' NOW (CHAIN 1).

The model I used:
original:

m1<- brm(log(betsize) ~ highcontrol + highreward +  patient + highcontrol*highreward + patient*highcontrol + patient*highreward +   (1|id), data=slot23)

reduced version:

bm1<- brm(log(bet) ~ highcontrol + highreward, data = d)

Originally had a much larger model with almost 8000 observations (and random intercepst), so wondered if it is a memory issue, but now repeated with 150 observations.

Also tried two different computers. Same problem occurs:

Computer 1:

  • Operating System: MacOS Ventura 13.4.1
  • Processor: 2.4 GHz 8-Core Intel Core i9
  • brms Version: 2.19.6

Computer 2:

  • Operating System: MacOS Venture 13.4
  • Processor: Apple M2
  • brms Version: 2.19.6

Some additional info: I tried the regular install of brms via install.packages and the direct install via the GitRepo. The brms package is loading here is the text

> library(brms)
> Loading required package: Rcpp
> Registered S3 method overwritten by 'htmlwidgets':
>   method           from         
>   print.htmlwidget tools:rstudio
> Loading 'brms' package (version 2.19.6). Useful instructions
> can be found by typing help('brms'). A more detailed introduction
> to the package is available through vignette('brms_overview').
> 
> Attaching package: ‘brms’
> 
> The following object is masked from ‘package:stats’:
> 
>     ar

Also tried what someone suggested in another thread here to run:

library(inline)
example(stan_model, package = "rstan", run.dontrun = TRUE)

This also causes a Fatal Error after successfully Translating and parsing the Stan Model and compiling the C Code.

Really appreciate help here. :-)

Hi @frederike-petzschner, welcome to Stan forums and sorry nobody responded sooner!

Can you try installing rstan (and StanHeaders) from source? (By default on Mac it will install binaries, but forcing it to install from source might fix this.)

# this might take a little while
Sys.setenv(MAKEFLAGS = "-j4") # speed up install using multiple cores
install.packages(c("StanHeaders", "rstan"), type = "source")

You may get a bunch of compiler warnings, but if there are only warnings and no fatal error then can you try running brms again and see if that works?

If that doesn’t work let us know and we can try something else.

Sorry again for the slow reply!

Thank you for getting back to me. I should have sent an update. This had already fixed it for me: Installing Rstan

Ok great, glad it’s working for you.

When I run this command, the following error message results:
Warning in install.packages :
Installation of package ‘rstan’ had exit status not equal 0