Skip to content

bayprior

0.4.0Package record

Bayesian Prior Elicitation, Diagnostics, and Regulatory Reporting

0packages depend
1.8Kdownloads / year
33.0%test coverage
13/13flavors OK

Overview

About

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.

Changes in 0.4.0

New features

  • prior_conflict() gains an exact argument (default FALSE, matching prior behaviour exactly). exact = TRUE replaces the Normal approximation to the prior and to the data likelihood -- used by default for box_pvalue and the s_value derived 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 against type = "binary" data) and Gamma-Poisson/Negative Binomial (a Gamma prior against type = "poisson" or type = "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 = TRUE falls back to the Normal approximation with a message rather than erroring; $box_pvalue_method on the returned object reports which was used ("exact" or "normal_approx"). surprise_index, kl_prior_likelihood, and overlap are unaffected by exact, 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) -- bayprior has no dependency, direct or optional, on any external meta-analysis package for this. outcome_type presets 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 around metafor::escalc() (Suggests, not Imports) that converts raw per-trial summary statistics (event counts, arm means/SDs, ...) into the y/se inputs map_prior() expects, across all six supported outcome_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 reports s_value, the surprisal -log2(box_pvalue) in bits -- an exploratory, continuous companion to the existing Box p-value / thresholded conflict_severity classification, 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 console print() method, the Shiny Conflict Diagnostics tab, and the prior_report() regulatory report.

Shiny app

  • Restyled the app around the package palette (navy and emerald). The stylesheet custom.css shipped 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

CRAN checks
13OK
Slowest check: 7.8 min · r-oldrel-macos-x86_64
Status changes
  • OK13 OK2026-08-05
  • NOTE12 OK, 1 NOTE2026-08-01
  • OK12 OK2026-06-09
  • ERROR11 OK, 1 ERROR2026-06-08
  • OK6 OK2026-06-04
Advisories

none known

Documentation

In release 0.4.0
READMEYes · 1,593 wordsVignettesYes · 7 · evaluation depends on the environmentNEWSYes · 100% structured · mentions 0.4.0Citation fileYes · computed when R runs it
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

1.8K
CRAN downloads in the past year
Rank #8,030 · ~5/day · ~153/mo
Daily download trend is not available in this view yet.
45330 days
1.1K90 days
1.8K1 year
Compare downloads with other packages →
Also on62 r2u29 autocran

Repository

2Stars
0Forks
2Open issues
1Open PRs
15Releases
284Commits
1Commit identities
bayesianrshinyr-packageclinical-trialspharmareporting
284 commits · Last activity 2026-10-17 · 0% stars, 30d
Responsiveness
How these are sampled
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

2026-04-24 · 12026-09-04 · 2
PracticesBeta

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.

Continuous integration (2)
GitHub ActionsR CMD check workflow

The R CMD check workflow runs on Linux, macOS and Windows, and on R-devel

Governance and community (3)
Code of conductIssue templatesPR template
Docs source (3)
Quarto project

GitHub Pages site last deployed 2026-10-09 · The repository has a site deploy workflow

Coverage (1)
Coverage reporting (Codecov)
Show all practicesHide 2 practices
CRAN release process (1)
cran-comments.md
Lint, format, editor (1)
RStudio project
How this is detected·Detection ruleset v3 (2026-09-26)

Dependencies

Declared dependencies
28 external dependencies (excludes base and recommended)

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.

Depends (1)
R >= 4.1.0
LinkingTo (0)
none
Enhances (0)
none
Reverse dependencies
0direct
0indirect

Nothing depends on this yet.

People & History

People (1)
Author, Maintainer since 0.2.12 (2026)
Releases (4)

Pick two releases to compare their code metrics.

  • 0.4.0Latest
    record
    2026-08-19 · current release · diff ↗ ·
    added 4 exports
    historical_effect_sizes, map_prior, plot_tau_posterior, resolve_tau_prior
  • 0.3.2
    record
    2026-08-19 · diff ↗
  • 0.3.0
    record
    2026-07-30 · diff ↗
  • 0.2.12
    record
    2026-06-03
  • R
    R 4.6.0 released · 2026-04-24

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.

APA

Balamuta, J. J. (2026). R Observatory: Metrics for bayprior version 0.4.0 [Data set]. HJJB, LLC. Data release v2026-10-19. https://doi.org/10.5281/zenodo.21843040

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.

Report a problem with this page →

Privacy choices

These apply to this browser and are stored on this device only. Nothing about your choice is sent to us.

Read the privacy policy