Hi
I would like to use “ppc_dens_overlay()” to display prior predictive distributions, but it requires the user to add a vector y along with the matrix with draws yrep. Is there a way to run ppc_dens_overlay without having to display y? Or maybe make it invisible? If there is a better alternative to ppc_dens_overlay() I’m also happy to try it
This is a bit of a hack, but you can use ppc_data and build the density plot yourself:
library(bayesplot)
#> This is bayesplot version 1.7.2.9000
#> - Online documentation and vignettes at mc-stan.org/bayesplot
#> - bayesplot theme set to bayesplot::theme_default()
#> * Does _not_ affect other ggplot2 plots
#> * See ?bayesplot_theme_set for details on theme setting
library(ggplot2)
y <- example_y_data()
y_rep <- example_yrep_draws()
ppc_data <- ppc_data(
y,
y_rep
)
ggplot(ppc_data, aes(x = value, group = rep_id)) +
geom_density(col = alpha(color_scheme_get()[3], 0.2)) +
bayesplot_theme_get()
Good question @fsdias and thanks @hhau for the nice solution. There’s actually a branch of bayesplot on GitHub that adds versions of many of the bayesplot functions but without taking a y argument. These functions start with prefix ppd_ instead of ppc_ since they’re just plots of the predictive distribution with no “checking” against data:
If you want to try using that branch then you can install it with
I’m not entirely sure if/when this will make it into a bayesplot release since it’s a huge PR that still needs to be reviewed, but I think it should be working properly if you try it out.