I am attempting to extract the warnings that were generated during the fitting of a Bayesian model using the brms::brm()
function, after the model has already been fitted.
Consider the following model as an example:
mdl <- brms::brm(Sepal.Length ~ Sepal.Width*Petal.Length*Petal.Width,
data = iris, seed = 123)
saveRDS(mdl, file = 'mdl.rds')
Upon fitting, I receive two warning messages:
Warning messages:
1: There were 8 transitions after warmup that exceeded the maximum treedepth. Increase max_treedepth above 10. See
https://mc-stan.org/misc/warnings.html#maximum-treedepth-exceeded
2: Examine the pairs() plot to diagnose sampling problems
Now, if I save the model and restart the session I’d like to be able to retrieve those warnings from the mdl
object. I am unable to retrieve the warnings using the following command:
mdl <- readRDS(file = 'mdl.rds')
mdl # The warnings do not show up
warnings(mdl)
My goal is to retrieve the warnings from a series of .rds files that contain models fitted with brm()
. I am aware that I could save the warnings along with the model during the fitting process (as discussed in my previous post), but that is not the solution I am seeking in this case.
How can I extract these warnings?