Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suggestion: Add alternative uncertainty notation for rvar #299

Open
StaffanBetner opened this issue Sep 12, 2023 · 1 comment
Open

Suggestion: Add alternative uncertainty notation for rvar #299

StaffanBetner opened this issue Sep 12, 2023 · 1 comment
Labels
feature New feature or request

Comments

@StaffanBetner
Copy link

StaffanBetner commented Sep 12, 2023

While the current rvar notation of mean ± sd is straightforward, I think it might be beneficial to offer alternative notations. I've found the mean(sd) style to be quite popular in some contexts, e.g. in physics and chemistry.

To give a bit of context, the R package errors offers a similar functionality to rvar, but it is only based on mean and standard deviation:

> library(posterior)
> library(errors)
> set.seed(19725654)
> rnorm(100, mean = 5, sd=10) -> x
> mean(x)
[1] 5.892738
> sd(x)
[1] 11.32585
> errors::set_errors(mean(x), sd(x))
6(10)
> posterior::rvar(x)
rvar<100>[1] mean ± sd:
[1] 5.9 ± 11 

Considering this, would it be possible to introduce an R option, say rvar.uncertainty.notation? This could let users choose between the current plusminus style and the alternative parenthesis notation.

Thanks for considering!

@mjskay
Copy link
Collaborator

mjskay commented Sep 12, 2023

Doesn't seem unreasonable. We already change the output notation to show (scaled) entropy for factors and dissent for ordered factors; something like this:

> posterior::rvar(letters)
rvar_factor<26>[1] mode <entropy>:
[1] a <1> 
26 levels: a b c d e f g h i j k l m n o p q r s t u v w x y z

Since we already have a summary option to print.rvar() that determines the summary functions used, with default determined by getOption("posterior.rvar_summary"), I'd propose a notation option to print.rvar() with default determined by getOption("posterior.rvar_notation"), with three possible values:

  • "plus_minus": current behavior: plus/minus for numeric rvars, <...> for factor/ordered
  • "chevrons": <...> for everything
  • "parens": (...) for everything

We could also allow more custom formatting, e.g. by allowing notation to take a function that takes a character vector (or maybe numeric vector) of measures of uncertainty and returns a character vector of the same length, formatted as desired. Not sure if this level of customization is really necessary, because at that point you might as well just start formatting things manually by calling the summary functions directly.

@paul-buerkner paul-buerkner added the feature New feature or request label Oct 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants