How to change default quantiles for summary statistics of "cmdstan::as_cmdstan_fit"

Hi all, how do we change the summary result, which shows 5th and 95th percentiles to, say, 2.5 and 97.5 percentiles? I use cmdstan via the terminal and then process with cmdstanr. I can do it manually, but I wish to change simply the default

Thank you in advance

Example of doing that:

fit$summary(NULL, ~quantile(.x, probs = c(0.4, 0.6)))

fit$summary() is just a wrapper to

posterior::summarize_draws(fit$draws(), posterior::default_summary_measures())

See docs for the summarize_draws Summaries of draws objects — draws_summary • posterior.

1 Like

it would be nice to have an example in the CmdStanR docs.
I spent 15 minutes guessing how the “…” in the R docs and
trying to understand posterior’s ‘summarise_draws’ documentation.
after much trial and error, I figured out the above.

I’m not an R developer, and that’s the problem here.
the docs for the posterior package are written for the developers
using this package.

also, I have no idea how R’s S3 classes and how the “…” in the args works.
most users don’t either
the CmdStanR docs need more examples.

1 Like

For here, I still think how just to show q2.5 and q97.5 instead of q5 and q95, and keep all other parameters.

The command:
fit$summary(NULL, ~quantile(.x, probs = c(0.4, 0.6)))
would really show the specified pair of quantiles

1 Like

filed an issue on this one: document how to get a custom summary from CmdStanMCMC sample via print function. · Issue #617 · stan-dev/cmdstanr · GitHub