How can I extract the model runtime from a model that was already fitted using brms with the cmdstanr backend? For instance, let’s say I load a brms model object that had been previously estimated using the cmdstanr backend. How can I find how long it took to estimate the model? When fitting the model, it shows how long it took to fit. But I’d like to extract that information from a previously estimated model.
Here’s some example code of a model that has already been estimated:
The rstan package has the get_elapsed_time() function for this. So you would run rstan::get_elapsed_time(model_fit$fit).
The one subtlety is that get_elapsed_time() has to be run on the stanfit object returned by stan, which actually does the model fitting. For models fit with brms, the stanfit object is stored in the fit element of the brmsfit object returned by brm. That’s why the argument to get_elapsed_time is model_fit$fit instead of just model_fit.