Generate posterior draws for each AE-drug combination
Source:R/pvEBayes_object_S3_methods.R
posterior_draws.RdThis function generates posterior draws from the posterior distribution of \(\lambda_{ij}\) for each AE-drug combination, based on a fitted empirical Bayes model. The posterior draws can be used to compute credible intervals, visualize posterior distributions, or support downstream inference.
Arguments
- obj
a
pvEBayesobject, which is the output of the function pvEBayes or pvEBayes_tune.- n_posterior_draws
number of posterior draws for each AE-drug combination.
- verbose
logical. If is TRUE (default), a progress bar is displayed to the console.
Examples
fit <- pvEBayes(
contin_table = statin2025_44, model = "general-gamma",
alpha = 0.3, n_posterior_draws = NULL
)
#> ℹ Fitting general-gamma model...
#> ✔ Fitting general-gamma model... [217ms]
#>
#> Object of class 'pvEBayes'
#>
#> General-gamma model with hyperparameter alpha = 0.3.
#> Estimated prior is a mixture of 18 gamma distributions.
#>
#> Running time of the general-gamma model fitting: 0.224 seconds.
#> Optimizer convergence: successful.
#> No posterior draws were generated.
#>
#> Extract estimated prior parameters, discovered signals
#> and signal strength posterior draws using `summary()`.
fit_with_draws <- posterior_draws(fit, n_posterior_draws = 1000)
#> ℹ Generating 1000 posterior draws...
#> ✔ Generating 1000 posterior draws... [36ms]
#>