- Notifications
You must be signed in to change notification settings - Fork12
R package for Bayesian meta-analysis models, using Stan
License
wwiecek/baggr
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
This isbaggr, anR package for Bayesianmeta-analysis usingStan.Baggr is intended tobe user-friendly and transparent so that it’s easier to understand themodels you are building and criticise them.
Baggr provides a suite of models that work with both summary data andfull data sets, to synthesise evidence collected from different groups,contexts or time periods. Thebaggr() command automatically detectsthe data type and, by default, fits a partial pooling model (which youmay know asrandom effectsmodels)with weakly informative priors by callingStanto carry out Bayesian inference. Modelling of variances or quantiles,standardisation and transformation of data is also possible.
The current version is a stable version of a tool that’s in activedevelopment so we are counting on your feedback.
Before starting, please followthe installation instructions forRStan,which is responsible for Bayesian inference inbaggr. If you don’thave Stan, it’s worth following the instructions step-by-step.
The package itself is available on CRAN:
install.packages("baggr")You can also install the most up-to-date version ofbaggr directlyfrom GitHub; this is what we recommend, but to do that you will need theremotes package:
#installation this way may take 5-15 minutesremotes::install_github("wwiecek/baggr",ref="devel",#if problems try changing to ref = "master"build_vignettes=TRUE,quiet=TRUE,build_opts= c("--no-resave-data","--no-manual"))
Most common issue in installingbaggr is with updating other packages.Try updating your packages (and ensure R is at least version 4) beforetrying theremotes command.
baggr is designed to work well with both individual-level (“full”) andaggregate/summary (“group”) data on treatment effect. In basic cases,only the summary information on treatment effects (such as means andtheir standard errors) is needed. Data are always specified in a singleinput data frame and the samebaggr() function is used for differentmodels.
For the “standard” cases of modelling means, the appropriate model isdetected from the shape of data.
library(baggr)df_pooled<-data.frame("tau"= c(28,8,-3,7,-1,1,18,12),"se"= c(15,10,16,11,9,11,10,18))bg<- baggr(df_pooled,pooling="partial")
You can specify the model type from several choices, the pooling type("none","partial" or"full"), and certain aspects of the priors,as well as other options for data preparation, prediction and more. Youcan access the underlyingstanfit object throughbg$fit.
Flexible plotting methods are included, together with an automaticcomparison of multiple models (e.g. comparing no, partial and fullpooling) throughbaggr_compare() command. Various statistics can becalculated: in particular,pooling() for pooling metrics andloocv()for leave-one-group-out cross-validation, allowing us to then compareand select models vialoo_compare(). Forest plots and plots oftreatment effects are available.
Tryvignette('baggr') for an overview of these functions and anexample of meta-analysis workflow withbaggr. If working with binarydata, tryvignette("baggr_binary"). Compiled vignettes are availableon CRAN.
Included in baggr v0.7 (2023):
- Meta-analysis of continuous and binary outcomes
- Both full and aggregate data sets can be used
- Summaries and plots specific to meta-analysis, typical diagnosticplots
- Meta-regression / fixed effects modelling
- Compatibility with
rstanandbayesplotfeatures - Automatic choice of priors or “plain-text” specification of priors
- Calculation of pooling/heterogeneity metrics
- Cross-validation (leave-one-group-out)
- Prior and posterior predictive distributions
Check [NEWS.md] for more information on recent changes to the package.
About
R package for Bayesian meta-analysis models, using Stan
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
Uh oh!
There was an error while loading.Please reload this page.
Contributors5
Uh oh!
There was an error while loading.Please reload this page.