Qian Sophia Zhang
2016-Aug-25 00:34 UTC
[R] How do you capture warning messages from rstan package's stan() function, when running an R script that calls stan() on the command line?
Hi R people, I have an R script Fit12_for_stack.R that calls rstan?s stan(). When I run the code in an interactive R session, I see warning messages from stan() about divergent transitions, but when I run the code on the command line with ?Rscript Fit12_for_stack.R?, I don?t see stan() warning messages. How can I run the code on the command line and still see stan() warning messages?>From the post How to save all console output to file in R? <http://stackoverflow.com/questions/7096989/how-to-save-all-console-output-to-file-in-r>, I tried addingcon <- file("test.log") sink(con, append=TRUE) sink(con, append=TRUE, type="message") to the top of Fit12_for_stack.R, but test.log again showed output, without stan() warning messages. Fit12_for_stack.R and a file it uses, try8.stan, are attached. Thanks, Qian P.S. If you prefer responding via StackExchange, I also posted there: http://stackoverflow.com/questions/39134667/how-can-i-capture-warning-messages-from-rstan-r-packages-stan-function-when <http://stackoverflow.com/questions/39134667/how-can-i-capture-warning-messages-from-rstan-r-packages-stan-function-when>.