Skip to content

(marginal) PPD plots #425

@mattansb

Description

@mattansb

Currently, the ppd_* functions are essentially the ppc_* functions without the y (observed data).
However, this isn't "the" (marginal) PPD - it shows individual replications:

library(bayesplot)
library(ggplot2)

set.seed(20260225)
mu_posterior <- rnorm(100, mean = 3, sd = 1)
sigma_posterior <- rgamma(100, shape = 2, rate = 1)

ypred <- t(mapply(rnorm, mu_posterior, sigma_posterior, n = 50))

ppd_dens_overlay(ypred) + 
  ggtitle("Replications of the posterior predictive distribution")

ppd_dens_overlay(ypred) +
  geom_density(aes(group = NA), linewidth = 1) +
  ggtitle("Replications of the posterior predictive distribution + marginal PPD")

Created on 2026-02-25 with reprex v2.1.1

It would be useful to allow the ppd_* functions to show the PPD (in addition to or instead of the individual replications).

E.g., this last plot (IMO) provides a good visualization of the epistemic vs aleatoric uncertainty in the PPD.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions