posterior icon indicating copy to clipboard operation
posterior copied to clipboard

brms_summary_measures()

Open ASKurz opened this issue 3 years ago • 9 comments

It would be nice if there was a summarise_draws() helper function along the lines of brms_summary_measures(), which only returned the typical four brms summary columns for the mean, SD, and 95% intervals.

ASKurz avatar May 09 '22 14:05 ASKurz

I like the idea. Would you like them to have the same names as currently in brms?

paul-buerkner avatar May 31 '22 07:05 paul-buerkner

I do like the way posterior names those columns mean, sd, q2.5, and q97.5. But then again, I can also see an argument for following the typical brms naming conventions. Would it be terrible to include something like a col_name argument that let the user choose between brms or posterior, where the brms option returned the typical brms names and posterior returned the more streamlined posterior like names?

ASKurz avatar May 31 '22 13:05 ASKurz

Would it be terrible to include something like a col_name argument that let the user choose between brms or posterior, where the brms option returned the typical brms names and posterior returned the more streamlined posterior like names?

That seems like a very use-case-specific argument to add. The more generic approach is probably something like your initial suggestion (a brms_summary_measures() function which can be passed to summarise_draws()).

mjskay avatar May 31 '22 17:05 mjskay

Maybe I should clarify that I meant for the col_name argument to live within the proposed brms_summary_measures(), not within the summarise_draws() function.

ASKurz avatar May 31 '22 18:05 ASKurz

I agree. We could have something like

brms_summary_measures(robust = FALSE, names = "posterior")

where robust decides on whether we use mean/sd or median/mad. And names could be either "brms" or "posterior". The reason I prefer "posterior" as default is that eventually in brms 3.0, brms names will be aligned with posterior names anyway.

What do you think?

paul-buerkner avatar May 31 '22 19:05 paul-buerkner

I like it and I'm also glad to hear the brms default names will be changing in version 3.0. The posterior versions of the names are much easier to type.

ASKurz avatar May 31 '22 19:05 ASKurz

Where is brms_summary_measures() documented? I couldn't find it with google search. I'm asking as what I would like to have is pretty printing like rstan::monitor() which accepts also digits argument. This would be useful in many case study notebooks. Here's an example of rstan::monitor() output

> monitor(samp, probs = c(0.25, 0.5, 0.75), digits_summary = 2)
Inference for the input samples (1 chains: each with iter = 2001; warmup = 1000):

     Q5 Q50 Q95 Mean  SD  Rhat Bulk_ESS Tail_ESS
V1 -0.9 0.2 1.5  0.2 0.8  1.14        5       15
V2 -0.9 0.2 1.5  0.2 0.8  1.15        5       18

For each parameter, Bulk_ESS and Tail_ESS are crude measures of 
effective sample size for bulk and tail quantities respectively (an ESS > 100 
per chain is considered good), and Rhat is the potential scale reduction 
factor on rank normalized split chains (at convergence, Rhat <= 1.05).

What I specifically like that I can choose the number of digits, and ESS's are always rounded to integer. As comparison the summarise_draws() looks like

> summarise_draws(samp)
# A tibble: 2 × 10
  variable    mean median    sd   mad    q5   q95  rhat ess_bulk ess_tail
  <chr>      <dbl>  <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>    <dbl>    <dbl>
1 ...1     -0.0568 -0.217 0.787 0.759 -1.24  1.36  1.13     6.30     44.2
2 ...2     -0.0557 -0.199 0.791 0.778 -1.21  1.38  1.13     6.55     44.3

If I guessed the purpose of brms_summary_measures() wrong, I can create another issue for pretty-printing diagnostic summaries.

avehtari avatar Aug 29 '22 16:08 avehtari

I think the brms_summary_measures just gives you the names of the functions that brms uses in its summary output. The printing output is currently handled by tibble directly since the output of summarise_draws is just a tibble. One way forward would be to add an additional class name for the output whose default printing we could adjust.

paul-buerkner avatar Aug 29 '22 16:08 paul-buerkner

Ok, I made a new issue for the pretty printing (which refers to related issues)

avehtari avatar Aug 29 '22 18:08 avehtari