Overview
bayesfoRest is an R package for creating publication-ready forest plots from Bayesian meta-analyses. It provides a comprehensive solution for visualizing meta-analytic results with support for various effect measures, subgroup analyses, and risk of bias assessments.
Key Features
- Bayesian Forest Plots: Create forest plots from brms models with customizable aesthetics
- Multiple Effect Measures: Support for OR, HR, RR, IRR, MD, and SMD
- Subgroup Analysis: Built-in support for subgroup meta-analyses
- Risk of Bias Integration: Seamlessly incorporate risk of bias assessments (RoB2, ROBINS-I, ROBINS-E, QUADAS-2)
- Shrinkage Visualisation: Display shrinkage effects with density plots or point intervals
- ROPE Support: Add Region of Practical Equivalence (ROPE) to plots
- Extensive Customisation: Colours, fonts, labels, and layout
Installation
You can install the development version of bayesfoRest from GitHub:
# install.packages("devtools")
devtools::install_github("BLMoran/bayesfoRest")Basic Usage
Binary Outcome Forest Plot (Odds Ratio)
bayes_forest(
model = model_bin,
data = binary_outcome,
measure = "OR",
xlim = c(0.1, 3.5)
)
Add Subgroups
bayes_forest(
model = model_bin,
data = binary_outcome,
measure = "OR",
subgroup = T,
xlim = c(0.1, 3.5)
)
Add Risk of Bias Columns
bayes_forest(
model = model_bin,
data = binary_outcome,
measure = "OR",
subgroup = T,
add_rob = T,
xlim = c(0.1, 3.5)
)
Add Risk of Bias Legend
bayes_forest(
model = model_bin,
data = binary_outcome,
measure = "OR",
subgroup = T,
add_rob = T,
add_rob_legend = T,
rob_tool = "rob2",
xlim = c(0.1, 3.5)
)
Exclude Studies with High Risk of Bias
bayes_forest(
model = model_bin,
data = binary_outcome,
measure = "OR",
subgroup = T,
add_rob = T,
add_rob_legend = T,
rob_tool = "rob2",
exclude_high_rob = T,
xlim = c(0.1, 3.5)
)
Standalone Risk of Bias Plot
# Create standalone RoB visualization
rob_plot(
data = binary_outcome,
rob_tool = "rob2",
add_rob_legend = TRUE
)
Overall Plot
# Create overall plot
overall_plot(
data = binary_outcome,
model = model_bin,
measure = "OR",
study_var = "Author",
incl_tau = T,
incl_mu_prior = T,
incl_tau_prior = T,
mu_xlim = c(0.1, 3.5),
tau_xlim = c(0, 1),
plot_arrangement = "vertical"
)
Sensitivity Plot
# Create sensitivity plot with different priors and meta-analysis models
sensitivity_plot(
model = model_bin,
data = binary_outcome,
measure = "OR",
study_var = Author,
rob_var = Overall,
exclude_high_rob = T,
incl_pet_peese = T,
incl_mixture = T,
incl_bma = T,
model_bma = robma_fits_bin,
add_probs = F,
priors = list(
vague = prior(normal(0, 10), class = "Intercept"),
weakreg = prior(normal(0, 1), class = "Intercept"),
informative = prior(normal(0, 0.5), class = "Intercept")),
xlim = c(0.25, 1.5),
add_null_range = T
)
Sensitivity Plot with Probabilities
# Create sensitivity plot with different priors and meta-analysis models with probabilities
sensitivity_plot(
model = model_bin,
data = binary_outcome,
measure = "OR",
study_var = Author,
rob_var = Overall,
exclude_high_rob = T,
incl_pet_peese = T,
incl_mixture = T,
incl_bma = T,
model_bma = robma_fits_bin,
add_probs = T,
priors = list(
vague = prior(normal(0, 10), class = "Intercept"),
weakreg = prior(normal(0, 1), class = "Intercept"),
informative = prior(normal(0, 0.5), class = "Intercept")),
xlim = c(0.25, 1.5),
add_null_range = T
)
ECDF Plot
# Create ECDF plot with different meta-analysis models
ecdf_plot(
model = model_bin,
data = binary_outcome,
measure = "OR",
study_var = Author,
rob_var = Overall,
priors = list(
weakreg = prior(normal(0, 1), class = "Intercept")),
exclude_high_rob = T,
incl_pet_peese = T,
incl_mixture = T,
incl_bma = T,
model_bma = robma_fits_bin,
xlim = c(0.25, 1.5),
add_null_range = T,
prob_reference = "null"
)
Dependencies
bayesfoRest depends on several R packages:
- brms for Bayesian model fitting
- metafor for meta-analysis preparation
- gt for creating tables
- patchwork for combining plots
- ggplot2 for plotting
- ggdist for density plotting
- tidybayes for tidy workflow
- dplyr, tidyr, purrr for data manipulation
- paletteer for colour palettes
- fontawesome for risk of bias icons
Feedback, Issues and Contributing
We welcome feedback, suggestions, issues and contributions. Please feel free to contact either Ben or Tom with any feedback. For any bugs, please file it here with a minimal code example to reproduce the issue. Pull requests can be made here. Please note that the bayesfoRest project is released with a Contributor Code of Conduct. By contributing to this project, you agree to abide by its terms.
