easystats / bayestestR

:ghost: Utilities for analyzing Bayesian models and posterior distributions
https://easystats.github.io/bayestestR/
GNU General Public License v3.0
577 stars 55 forks source link

Value formatting of p_rope in print.describe_posterior #305

Closed mattansb closed 4 years ago

mattansb commented 4 years ago

Why does p_rope become ROPE_Percentage in describe_posterior()? The value is not a % (0-100)... can be misleading.

library(bayestestR)

x <- rnorm(30)

describe_posterior(x)
#>   Parameter     Median CI    CI_low  CI_high  pd ROPE_CI ROPE_low ROPE_high
#> 1 Posterior -0.4561895 89 -1.815983 1.479632 0.6      89     -0.1       0.1
#>   ROPE_Percentage
#> 1      0.07142857
p_rope(x)
#>   ROPE_low ROPE_high p_ROPE
#> 1     -0.1       0.1  0.067

Created on 2020-04-20 by the reprex package (v0.3.0)

strengejacke commented 4 years ago

Why does p_rope become ROPE_Percentage in describe_posterior()?

It does not. ROPE_percentage refers to the equivalence testing or rope.

library(bayestestR)

x <- rnorm(30)

describe_posterior(x, test = "p_rope")
#>   Parameter    Median CI     CI_low  CI_high ROPE_low ROPE_high    p_ROPE
#> 1 Posterior 0.2366907 89 -0.9916277 1.562566     -0.1       0.1 0.1333333
p_rope(x)
#>   ROPE_low ROPE_high p_ROPE
#> 1     -0.1       0.1   0.13

Created on 2020-04-20 by the reprex package (v0.3.0)

mattansb commented 4 years ago

Oh... Okay 😅

Then shouldn't it be a percent? 0.13 > 13? @DominiqueMakowski

strengejacke commented 4 years ago

The value should be .13, but the print-method should probably transform this in a %?

mattansb commented 4 years ago

I think so.

nahorp commented 4 years ago

Thanks for posting this @mattansb, appreciate it.

Indeed, either a) the print method for describe_posterior should transform it to a % since the heading does say "ROPE_percentage" or b) the heading for that value should be changed to "p_rope".

This would (maybe) help reduce interpretation issues...

strengejacke commented 4 years ago
library(bayestestR)
library(rstanarm)

x <- rnorm(30)
model <- stan_glm(mpg ~ wt + gear, data = mtcars, chains = 2, iter = 200, refresh = 0)

describe_posterior(x)
#> # Description of Posterior Distributions
#> 
#> Parameter | Median |          89% CI |    pd |        89% ROPE | % in ROPE
#> --------------------------------------------------------------------------
#> Posterior | -0.175 | [-1.575, 1.648] | 0.600 | [-0.100, 0.100] |    14.286

describe_posterior(x, ci = c(.8, .9))
#> # Description of Posterior Distributions
#> 
#> Parameter | Median |                     CI |    pd |        89% ROPE | % in ROPE
#> ---------------------------------------------------------------------------------
#> Posterior | -0.175 | 80% CI [-1.383, 0.847] | 0.600 | [-0.100, 0.100] |    14.286
#> Posterior | -0.175 | 90% CI [-1.575, 1.648] | 0.600 | [-0.100, 0.100] |    14.286

describe_posterior(model)
#> # Description of Posterior Distributions
#> 
#> Parameter   | Median |           89% CI |    pd |        89% ROPE | % in ROPE |  Rhat | ESS
#> -------------------------------------------------------------------------------------------
#> (Intercept) | 38.720 | [28.839, 47.119] | 1.000 | [-0.603, 0.603] |     0.000 | 0.998 | 206
#> wt          | -5.582 | [-6.774, -4.187] | 1.000 | [-0.603, 0.603] |     0.000 | 1.001 | 266
#> gear        | -0.255 | [-1.922,  1.201] | 0.605 | [-0.603, 0.603] |    56.425 | 1.000 | 195

describe_posterior(model, ci = c(.8, .9))
#> # Description of Posterior Distributions
#> 
#> Parameter   | Median |                      CI |    pd |        89% ROPE | % in ROPE |  Rhat | ESS
#> --------------------------------------------------------------------------------------------------
#> (Intercept) | 38.720 | 80% CI [33.320, 48.048] | 1.000 | [-0.603, 0.603] |     0.000 | 0.998 | 206
#> (Intercept) | 38.720 | 90% CI [29.127, 48.048] | 1.000 | [-0.603, 0.603] |     0.000 | 0.998 | 206
#> wt          | -5.582 | 80% CI [-6.494, -4.436] | 1.000 | [-0.603, 0.603] |     0.000 | 1.001 | 266
#> wt          | -5.582 | 90% CI [-6.728, -4.062] | 1.000 | [-0.603, 0.603] |     0.000 | 1.001 | 266
#> gear        | -0.255 | 80% CI [-1.493,  0.908] | 0.605 | [-0.603, 0.603] |    56.425 | 1.000 | 195
#> gear        | -0.255 | 90% CI [-1.894,  1.318] | 0.605 | [-0.603, 0.603] |    56.425 | 1.000 | 195

Created on 2020-05-11 by the reprex package (v0.3.0)

nahorp commented 4 years ago

Great, thanks @strengejacke! :)