Saving model chain progress output to file or to console

Hi,

I am running Stan models on my university’s computing server (linux system), by submitting a batch file that calls Rscript mymodel.R. Previously when I run rstan on my computer in RStudio, I can check the model chain progress in the RStudio Viewer console. I am wondering now if there is any way I can view my model progress when I run it on the server, or is there any way to write the model chain progress to the console or to a text file?

Thank you very much!

It appears as a text file in the tempdir() of the R process that is running mymodel.R. Usually, the cluster itself is going to have some mechanism to save stdout and stderr. What batch processing software is your server using to run jobs?

The server uses Moab to run jobs. I checked the manual and found the stdout file it saved and I have my chain progress written into this stdout file. So the problem is resolved. Thanks!

Hi! I have the same problem/question. I can’t find any temporary directories or stdout files. I’m running stan within an Rmd, and get:

“no method available for opening ‘file:///tmp/Rtmp2JHyvQ/file7a9105eafb6_StanProgress.html’”

It would be great to be able to see the progress of the chains. Do I modify open_progress somehow?

With open_progress = FALSE, I at least get output on progress to the PuTTY session (and don’t get the error above). But I can’t use sink() to get it to output to a .txt file.

Thanks!

When knitting an Rmd, it is going to be difficult to find what tempdir() is being used for that R session. I guess it will be whatever subdirectory of /tmp starting with Rtmp is most recently created.

I don’t see any /tmp directory. Is there a way to tell sampling() to output progress to a .txt file?

thanks!!

That is what it should be doing automatically, albeit to a temporary file. What does tempdir() say in a regular R session?

This is what tempdir() says, but I can’t see the directory when I “ls”?

tempdir()
[1] “/tmp/RtmpnPbwcm”
q()
Save workspace image? [y/n/c]: n
ubuntu@ip…:~$ ls -a
. .bashrc .profile .vimrc
… bin runstan.R .yadm
.aws .cache .ssh
.bash_history data .sudo_as_admin_successful
.bash_logout general_model.Rmd .tmux.conf

When you quit R, it deletes the temporary directory. You have to look at it from a different shell while R is running.

hmm, I still don’t see it:

. .bashrc .profile .vimrc
… bin runstan.R .yadm
.aws .cache .ssh
.bash_history data .sudo_as_admin_successful
.bash_logout general_model.Rmd .tmux.conf

That is the contents of your home directory. If you look at

ls /tmp/Rtmp*

it will be one of those.

got it! and found the relevant file. thanks so much!

Just wanted to add that using: qpeek job_id worked for me on a HPC.