Bayesian Prior Elicitation, Diagnostics, and Regulatory Reporting
Overview
A toolkit for constructing, validating, and justifying Bayesian priors in clinical trial settings. Implements expert elicitation via quantile matching, the roulette method, and moment matching across six distribution families, linear and logarithmic expert pooling, meta-analytic-predictive (MAP) priors derived from historical trials, prior-data conflict diagnostics including the Box p-value (with an exact prior predictive option for selected prior and data combinations), an exploratory surprisal (S-value) companion to it, surprise index, information divergence, and Mahalanobis distance, sensitivity analyses with tornado and influence heatmap plots, sceptical, robust, and power priors, and automated prior justification reports. Includes a fully modular 'Shiny' application for interactive use. Methods based on O'Hagan et al. (2006, ISBN:9780470029886), Box (1980) doi:10.2307/2982063, Greenland (2023) doi:10.1111/sjos.12625, Oakley and O'Hagan (2010) https://tonyohagan.co.uk/shelf/, Schmidli et al. (2014) doi:10.1111/biom.12242, Neuenschwander et al. (2010) doi:10.1177/1740774509356002, Roever et al. (2021) doi:10.1002/jrsm.1475, Ibrahim and Chen (2000) doi:10.1214/ss/1009212673, Spiegelhalter et al. (1994) doi:10.2307/2983527.
New features
prior_conflict()gains anexactargument (defaultFALSE, matching prior behaviour exactly).exact = TRUEreplaces the Normal approximation to the prior and to the data likelihood -- used by default forbox_pvalueand thes_valuederived from it -- with the exact prior predictive distribution, for the prior family/data-type combinations where one has a closed form: Beta-Binomial (a Beta prior againsttype = "binary"data) and Gamma-Poisson/Negative Binomial (a Gamma prior againsttype = "poisson"ortype = "survival"data -- both reduce to the same events/exposure model, so one exact check covers both). The Normal-Normal case (type = "continuous"against a Normal prior) was already exact and needs no separate path. For prior family/data-type combinations with no closed-form check implemented,exact = TRUEfalls back to the Normal approximation with a message rather than erroring;$box_pvalue_methodon the returned object reports which was used ("exact" or "normal_approx").surprise_index,kl_prior_likelihood, andoverlapare unaffected byexact, since they are defined with respect to the Normal-approximated prior and likelihood regardless.
Show all changes in 0.4.0Hide the rest of the changes in 0.4.0
- Added
map_prior(): derives a meta-analytic-predictive (MAP) prior from historical trial summaries via a random-effects meta-analysis, with an explicit prior on the between-trial heterogeneity parameter tau (Schmidli et al., 2014). The meta-analysis engine is implemented entirely in base R: the posterior of mu given tau has a closed form, so the only numerical step is a one-dimensional integral over tau (stats::integrate()/stats::optimize()/stats::uniroot(), all base R) --baypriorhas no dependency, direct or optional, on any external meta-analysis package for this.outcome_typepresets select the default tau prior from Roever et al. (2021)'s outcome-specific recommendations, distinguishing a single-arm log-odds case (e.g. historical control response rates -- the typical MAP use case) from a two-arm log-odds ratio case, which get different default heterogeneity-prior scales despite both being "log-odds" in casual speech. - Added
historical_effect_sizes(), a thin wrapper aroundmetafor::escalc()(Suggests, notImports) that converts raw per-trial summary statistics (event counts, arm means/SDs, ...) into they/seinputsmap_prior()expects, across all six supportedoutcome_types. - Added a Shiny module for
map_prior(), "MAP Prior (Historical)", as its own top-level sidebar item alongside "Prior Elicitation" and "Expert Pooling" -- reflecting that MAP derivation is an alternative way to construct a base informative prior, not a robustness adjustment applied to one (Robust Mixture, Sceptical, and Power Prior all take an existing base prior as input; MAP produces one). Its step-completion indicator is tracked independently of Robust Priors' own. prior_conflict()now also reportss_value, the surprisal-log2(box_pvalue)in bits -- an exploratory, continuous companion to the existing Box p-value / thresholdedconflict_severityclassification, since prior-data conflict checks are typically not powered for a binary accept/reject decision. Reported alongside (not instead of) the existing diagnostics in the consoleprint()method, the Shiny Conflict Diagnostics tab, and theprior_report()regulatory report.
Shiny app
- Restyled the app around the package palette (navy and emerald). The stylesheet
custom.cssshipped with the app but was never linked, so it had no effect; it is now loaded, with dark-mode variants. Result tiles, box headers, alerts, and notifications use colour for status only, and text colours were checked for WCAG AA contrast. - The Welcome page workflow diagram is now live: steps link to their panels and show completed steps. A "Start here" panel (elicit, derive from historical trials, or load the TRIAL-001 example) becomes "Next steps" once a prior exists. The Report step is marked complete after a report is generated and reopens when the prior or any analysis changes.
- Fitting a prior (Parametric, Roulette, or MAP) while a pooled consensus prior is active now asks whether to replace the consensus or keep it, instead of leaving downstream steps on the old consensus without notice.
- Fixed a JavaScript error in the theme-toggle script, which ran before the page body existed and stopped the rest of the script from loading. The Auto / Dark / Light button label now shows correctly on load.
---
From NEWS.md in the release
Install
Health
- OK13 OK2026-08-05
- NOTE12 OK, 1 NOTE2026-08-01
- OK12 OK2026-06-09
- ERROR11 OK, 1 ERROR2026-06-08
- OK6 OK2026-06-04
Documentation
- Help pages
- 36 (3 internal)includes a package overview page
- Examples that run
- 100%22 run in a plain check (1 of them under a condition)
- Exported functions with examples
- 85%
- Documented parameters
- 99%
- Return-value docs
- 100%
- Help pages citing references
- 22%
Downloads
Repository
- PRs merged (all time)
- 100%
- Median days to close, 50 most recently updated closed issues
- 1
- Median days to close, 50 most recently updated closed PRs
- 0
Stars over time
Releases over time
Issues over time
PRs over time
Commits over time
11 development-tooling and community-health practices detected across 6 families in the upstream repository
Checks run against github.com/ndohpenngit/bayprior on 2026-10-11.
The R CMD check workflow runs on Linux, macOS and Windows, and on R-devel
GitHub Pages site last deployed 2026-10-09 · The repository has a site deploy workflow
Show all practicesHide 2 practices
Dependencies
Installing bayprior adds 77 packages (38 with compiled code, 74 MB of source tarballs). Heaviest: stringi 11 MB, ggplot2 6.0 MB, data.table 5.7 MB.
Code & Tests
People & History
Package metadata
- First published
- 2026-06-03
- Total releases
- 4 / 1 yrs
- License
- GPL-3 OSI
- Minimum R
- ≥ 4.1.0
- Download size
- 2.6 MB
Cite
Cite this package
Run in R for the authors' preferred citation:
citation("bayprior")The package provides a citation file that builds its entry when R runs it. Run citation() to see it.
Cite the R Observatory
For a number measured here: a download total, a coverage figure, an archival date.
From data release v2026-10-19, which the citation names so these numbers can be found later. More on citing and the projects behind them.