R package pvEBayes

CRAN status R-CMD-check Codecov test coverage CodeFactor License: GPL v3

pvEBayes is an R package that implements a suite of nonparametric empirical Bayes methods for pharmacovigilance, including the Gamma-Poisson Shrinker (GPS), K-gamma, general-gamma, Koenker-Mizera (KM), and Efron models. It provides tools for fitting these models to the spontaneous reporting system (SRS) frequency tables, extracting summaries, performing hyperparameter tuning, and generating graphical summaries (eye plots and heatmaps) for signal detection and signal strength estimation.

Spontaneous Reporting System (SRS) Table: An drug safety SRS dataset catalogs AE reports on I AE rows across J drug columns. Let \({N_{ij}}\) denote the number of reported cases for the i-th AE and the j-th drug, where \({i = 1,..., I}\) and \({j = 1,..., J}\).

Empirical Bayes modeling for disproportionality analysis:

From signal detection to signal strength \(\lambda\) estimation

Methods implemented in pvEBayes (differ by prior assumptions):

Why nonparametric priors?

Implementation highlights:

For a detailed methodological description, see Tan et al.  (Stat. in Med., 2025).

Installation

The stable version of pvEBayes can be installed from CRAN:

install.packages("pvEBayes")

The development version is available from GitHub:

# if (!requireNamespace("devtools")) install.packages("devtools")
devtools::install_github("YihaoTancn/pvEBayes")

Quick Example

Here is a minimal example analyzing the built-in FDA statin44 dataset with general-gamma model:


library(pvEBayes)

# Load the statin44 contingency table of 44 AEs for 6 statins
data("statin2025_44")

# Fit a general-gamma model with a specified alpha
fit <- pvEBayes(
  contin_table      = statin2025_44,
  model             = "general-gamma",
  alpha             = 0.3,
  n_posterior_draws = 1000
)

# Print out a concise description of the fitted model
fit

# Obtain a logical matrix for the detected signal
summary(fit, return = "detected signal")

# Visualize posterior distributions for top AE-drug pairs
plot(fit, type = "eyeplot")

For a more detailed illustration, please see ‘Vignette’.

License

pvEBayes is released under the GPL-3 license. See ‘LICENSE.md’ for details.

Code of Conduct

Please note that the pvEBayes project is released with a Contributor Code of Conduct. By contributing to this project, you agree to abide by its terms.

References

Tan Y, Markatou M and Chakraborty S. Flexible Empirical Bayesian Approaches to Pharmacovigilance for Simultaneous Signal Detection and Signal Strength Estimation in Spontaneous Reporting Systems Data. Statistics in Medicine. 2025; 44: 18-19, https://doi.org/10.1002/sim.70195.

Tan Y, Markatou M and Chakraborty S. pvEBayes: An R Package for Empirical Bayes Methods in Pharmacovigilance. arXiv:2512.01057 (stat.AP). https://doi.org/10.48550/arXiv.2512.01057

Koenker R, Mizera I. Convex Optimization, Shape Constraints, Compound Decisions, and Empirical Bayes Rules. Journal of the American Statistical Association 2014; 109(506): 674–685, https://doi.org/10.1080/01621459.2013.869224

Efron B. Empirical Bayes Deconvolution Estimates. Biometrika 2016; 103(1); 1-20, https://doi.org/10.1093/biomet/asv068

DuMouchel W. Bayesian data mining in large frequency tables, with an application to the FDA spontaneous reporting system. The American Statistician. 1999; 1;53(3):177-90.