stan-dev / posterior

The posterior R package
https://mc-stan.org/posterior/
Other
167 stars 23 forks source link

Pretty printing MCSE #120

Open avehtari opened 3 years ago

avehtari commented 3 years ago

In #117 I wrote

I don't know if this would make sense but adding here, that there could be something that would show the mcse in compact format. I assume it would require new variable type, like expectation variable evar, but I guess that could cause too much trouble even if it would look nice

E(eight_schools_rvars$mu, MCSE=TRUE)
evar[1] E ± MCSE:
[1] 4.2 ± .2

Pr(eight_schools_rvars$mu>0, MCSE=TRUE)
evar[1] Pr ± MCSE:
[1] 0.9 ± 0.02

Instead of an option, I guess different function name would be safer.

More I think it, more I dislike having yet another variable type, but I open the issue if there are ideas for otherwise make it easy to pretty print MCSE. Maybe a variant of summarize_draws or option for that, that would choose the numbers of digit to show best on MCSE and would show MCSE using ± as above?

The current way is to do

> summarize_draws(eight_schools_rvars$mu, mean, mcse_mean, quantile2, mcse_quantile)
# A tibble: 1 x 7
  variable                mean mcse_mean     q5   q95 mcse_q5 mcse_q95
  <chr>                  <dbl>     <dbl>  <dbl> <dbl>   <dbl>    <dbl>
1 eight_schools_rvars$mu  4.18     0.150 -0.854  9.39   0.551    0.415

and the difference would be that with pretty printing we could get something like

  variable                mean ± mcse   q5 ± mcse   q95 ± mcse 
1 eight_schools_rvars$mu  4.2 ± 0.2     0.9 ± 0.6   9.4 ± 0.4

where ± helps to group together the related information.

mjskay commented 3 years ago

This seems related to (or an alternative to?) #44