Terribly sorry for the delay, I was away for a few days. I’m not entirely sure where the crashing is coming from, since your script doesn’t replicate the behaviour for me on either a Windows or a Linux machine and none of the usual culprits for these crashes are present.
Does the crash happen if you use the default settings? As in, just specifying the model and the data, not the number of iterations or inits, etc.
If it still crashes, there are two things I would try. First, you can try running your model through the cmdstanR
package, which tends to be much more stable and also uses the latest release of Stan. Install instructions here: Getting started with CmdStanR • cmdstanr
Alternatively, you can try installing the experimental preview of the upcoming RStan 2.26. There may be some bugs, but that’s helpful for us to know about. To install, you need to restart your R session, and then run:
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")))