Closed DominiqueMakowski closed 4 years ago
I don't think it's too hard. We could have an argument like show_priors
or so, and then the layer for the prior can be completely independent from the remaining plot, it's just that we should add the prior layer first, and maybe add some alpha to both prior and posterior layer.
Here's a quick prototype:
library(see)
library(ggplot2)
library(bayestestR)
library(rstanarm)
model <- stan_glm(mpg ~ wt + am, data = mtcars, chains = 1)
p <- plot(point_estimate(model), panel = F)[[2]]
sp <- simulate_prior(model)
ed <- estimate_density(sp[["am"]])
p + geom_ribbon(
data = ed,
mapping = aes(
x = x,
ymin = 0,
ymax = y,
group = NA
),
fill = "#FFC107",
alpha = .3
)
Created on 2019-09-13 by the reprex package (v0.3.0)
We should probably think of limiting the range of the x-axis, though, since the prior usually is very wide compared to the posterior.
Nice!
We should probably think of limiting the range of the x-axis,
This is the case for default priors, in which case people are anyway usually not really interested in displaying them anyway, but when people care about the priors I guess it makes sense to display them entirely (even if the plot is uglier)
And you can add xlim(c(-20, 20))
or similar easily by yourself...
but when people care about the priors I guess it makes sense to display them entirely
True, but you still might want to limit the x axis in some way - for example, if a Cauchy prior is used, some very very extreme samples can be drawn - which not only messes up the x-axis, it also messes up the density estimation (which is where logspline
shines)...
See how I've dealt with this here (lines 377-390): https://github.com/easystats/bayestestR/blob/master/R/bayesfactor_parameters.R#L377
So you suggest limiting the range to +/- 7SD (or MAD)? Sounds feasible to me.
Yes, I suggest using MAD - SD gives a very wide window with Cauchy / t(df<3).
hm, doesn't geom_ridgeline_gradient
an alpha option?
ok, geom_ridgeline()
has, and I don't need geom_ridgeline_gradient() for the prior layer
It is probably better to add the prior layer onto the main layer for those plots where we have to use geom_ridgeline_gradient
, because that geom allows no alpha.
I started adding the prior-feature to some of the plots:
https://easystats.github.io/see/articles/bayestestR.html
show_priors
or just priors
?priors_alpha
?In some cases we hard-code colors (e.g. point-estimate). We may think changing this somewhen in the future...
Do we want the argument to be names show_priors or just priors?
add_priors
ot plot_priors
?Mattan S. Ben-Shachar, PhD student Department of Psychology & Zlotowski Center for Neuroscience Ben-Gurion University of the Negev The Developmental ERP Lab http://www.deverplab.com/ Personal Website https://sites.google.com/view/mattansb
On Fri, Sep 13, 2019 at 11:43 AM Daniel notifications@github.com wrote:
I started adding the prior-feature to some of the plots:
https://easystats.github.io/see/articles/bayestestR.html
- Do we want the argument to be names show_priors or just priors?
- What about the other arguments, like priors_alpha?
In some cases we hard-code colors (e.g. point-estimate). We may think changing this somewhen in the future...
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/easystats/see/issues/48?email_source=notifications&email_token=AINRP6A3LZPCLIMDDWMJFB3QJNHD3A5CNFSM4IWLZO2KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD6UMHUA#issuecomment-531153872, or mute the thread https://github.com/notifications/unsubscribe-auth/AINRP6EJ7RSPDSLMCDTKPCLQJNHD3ANCNFSM4IWLZO2A .
I like when args controlling a main arg stems out of it, so if we go for priors_alpha
it makes sense to leave it just as priors = TRUE
I'm not sure whether there are any plots left to add priors? For HDI, we have the simple density plots, so I think we don't additionally need this option for HDI, do we?
Now that priors can easily be extracted as distributions using
simulate_priors
, I wonder if it would be tough to give the option to add them in the posterior plots (so you can see for all parameters, the prior and the posterior)...