Comments (15)
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)
from see.
We should probably think of limiting the range of the x-axis, though, since the prior usually is very wide compared to the posterior.
from see.
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)
from see.
And you can add xlim(c(-20, 20))
or similar easily by yourself...
from see.
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
from see.
So you suggest limiting the range to +/- 7SD (or MAD)? Sounds feasible to me.
from see.
Yes, I suggest using MAD - SD gives a very wide window with Cauchy / t(df<3).
from see.
hm, doesn't geom_ridgeline_gradient
an alpha option?
from see.
ok, geom_ridgeline()
has, and I don't need geom_ridgeline_gradient() for the prior layer
from see.
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.
from see.
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 justpriors
? - 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...
from see.
from see.
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
from see.
from see.
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?
from see.
Related Issues (20)
- Option to only select fixed effects when plotting paramters of `gam()` model HOT 1
- Suggestion: `pretty_names` for `see:::plot.see_parameters_model()`
- Plotting the results of cluster analyses HOT 2
- Simplify `plot.parameters_model()` HOT 5
- Specifying jitter width is not working with visualisation_recipe
- Improved meta-analysis forest plotting
- `palette_colorhex()` requires R 4.1 to work
- DRY test datasets
- Reduce usage of pipes in the docs and tests
- Fix warning in `binned_residuals()` HOT 2
- plot.parameters_simulate formatting VS parameters_model formatting
- customize facet direction in plot.parameters_model HOT 2
- Figure legend in check predictions
- Error in model_parameters.aov plot() method? HOT 2
- Error in plot method with `describe_distribution()` HOT 1
- Plot method for `data_tabulate()`? HOT 2
- Improve plot() for check_predictions() HOT 11
- show_intercept = FALSE doesn't work for brms ordinal models HOT 5
- Relicensing `{see}` HOT 4
- Errors retrieving models when stan_glm is run inside a function
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from see.