Add prior_posterior_overlap() for quantifying prior-to-posterior learning

Open
#532 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
35/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Quiet
Tech stack
r

Research direction

Start by reviewing the existing mcmc_* input handling and the MCMCvis prior-to-posterior overlap behavior referenced in the issue. Define how matrix, 3D array, and draws-object inputs, parameter selection, and transformations should work; done means a prior_posterior_overlap() result with Parameter and Overlap columns using the stated 0-to-1 density-overlap measure.

Written by the indexing model from the issue text.

Description

Hi @jgabry — as part of my GSoC proposal work on prior vs posterior comparison plots, I've been prototyping different visualizations and one thing that kept coming up during testing was the need for a simple numeric summary of how much the posterior has moved away from the prior.

MCMCvis has something like this (MCMCtrace with PPO_out = TRUE), but bayesplot doesn't have an equivalent. I think a standalone prior_posterior_overlap() function would be useful even outside the context of the plotting module — it gives users a quick per-parameter number (0 = completely disjoint, 1 = identical) to answer "did my data actually inform this parameter?"

The implementation would be straightforward:

  • Accept posterior and prior draws in the standard bayesplot formats (matrix, 3D array, draws objects)
  • Support pars, regex_pars, transformations like other mcmc_* functions
  • Return a data frame with Parameter and Overlap columns
  • Overlap computed as the integral of min(f_prior, f_posterior) over a shared density grid

Would it make sense for me to implement this as a PR? Happy to hear your thoughts on scope or naming.

Dominant language
R
Stars
442
Forks
93
Avg merge
3h 17m
Merged PRs (30d)
2

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from stan-dev/bayesplot

All issues in stan-dev/bayesplot

Similar issues

More R issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.