Problem with Stan modeling extremely slow compilation

Good morning. I am coming back on the rstan functioning problem we had discussed last week. Prior to use Cmdstan, I would like to see if I can’t get rstan to work the usual way, it still looks the easiest way to me.

After restarting the computer, stan looks to be a little faster than it was on Friday. That being said, problems are still occurring : 1) R requires more time to compile and fit models that were working very smoothly on a less powerful computer 2) complex models that perfectly converged on my previous computer no longer do now with the same data (Rhat at 2 and all possible error messages coming out, diagnosing with shinystan shows that the chains don’t merge correctly) 3) I still have the strange problem that when I interrupt a fit, the model first seems to stop, but notifications of chain progression continue to appear until 100% is reached.

If this can help on point 3), there is one error message that appears when the chains reach 100 % (after the model is interrupted). It reads :

Error in serialize(data, node$con, xdr = FALSE) : ignoring SIGPIPE signal
Calls: … doTryCatch → sendData → sendData.SOCK0node → serialize
Execution halted

I tried some of your suggestions to solve the problem.

Regarding Xcode, it turns out that I don’t have it installed on my computer. I see it in the Appstore, but it doesn’t appear anywhere in my apps. Do you think installing it may help ?

I also tried to correct the problem of R not finding the right folder. I followed a tutorial to set up an R folder on my computer, and entered the following lines in a terminal :

mkdir ~/.R
nano ~/.R/Makevars

And then configuring the new folder with :

CXX14FLAGS=-O3 -march=native -fopenmp
CXX14=g++ -fopenmp

When I check R’s location with :

writeLines(readLines(file.path(Sys.getenv(“HOME”), “.R/Makevars”)))

I no longer get an error message but instead receive :

CXX14FLAGS=-O3 -march=native -fopenmp
CXX14=g++ -fopenmp

but does that mean R and all its dependencies are now present at the right location ? On my other computer, I had an R folder that appears on the left bar of my Finder, and I don’t see it now. Furthermore, I noticed that creating the R folder actually slowed the models. Before to create the folder, the chains of the most complex model I checked took between 125 and 200 seconds to complete, when I tried the fit after, the time increased to 240 and 340s, seen on all the later attempts.

Apart from the Xcode and folder things, could the problem be due to missing dependencies, or a question of R updates ? I am on R 4.4.1 on my new computer, I think I had an older version on the previous one. I guess you would have spotted it quickly if the problem came from here, but could it be that too ?

And if we don’t find any solution here, do you know any other resources or persons I could ask to solve the issue ?

Thank you for your answer.