diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml index 92243965..7b129337 100644 --- a/.github/workflows/R-CMD-check.yaml +++ b/.github/workflows/R-CMD-check.yaml @@ -83,7 +83,8 @@ jobs: run: | remotes::install_deps(dependencies = TRUE) remotes::install_cran("rcmdcheck") - remotes::install_version("BayesTools", "0.2.3") + #remotes::install_version("BayesTools", "0.2.3") + remotes::install_github("FBartos/BayesTools@v0.2.3") shell: Rscript {0} - name: Check diff --git a/.github/workflows/R-CMD-tests.yaml b/.github/workflows/R-CMD-tests.yaml index 6ea17164..f6dabfef 100644 --- a/.github/workflows/R-CMD-tests.yaml +++ b/.github/workflows/R-CMD-tests.yaml @@ -85,7 +85,8 @@ jobs: run: | remotes::install_deps(dependencies = TRUE) remotes::install_cran("rcmdcheck") - remotes::install_version("BayesTools", "0.1.3") + #remotes::install_version("BayesTools", "0.2.3") + remotes::install_github("FBartos/BayesTools@v0.2.3") install.packages("devtools") install.packages("testthat") install.packages("vdiffr") @@ -104,7 +105,8 @@ jobs: run: | remotes::install_deps(dependencies = TRUE) remotes::install_cran("rcmdcheck") - remotes::install_version("BayesTools", "0.2.3") + #remotes::install_version("BayesTools", "0.2.3") + remotes::install_github("FBartos/BayesTools@v0.2.3") install.packages("devtools") install.packages("testthat") install.packages("vdiffr") diff --git a/.github/workflows/pkgdown.yaml b/.github/workflows/pkgdown.yaml index e218b03b..a264c554 100644 --- a/.github/workflows/pkgdown.yaml +++ b/.github/workflows/pkgdown.yaml @@ -77,7 +77,8 @@ jobs: run: | remotes::install_deps(dependencies = TRUE) install.packages("pkgdown") - remotes::install_version("BayesTools", "0.2.3") + #remotes::install_version("BayesTools", "0.2.3") + remotes::install_github("FBartos/BayesTools@v0.2.3") shell: Rscript {0} - name: Install package diff --git a/.github/workflows/test-coverage.yaml b/.github/workflows/test-coverage.yaml index 1a3cc7e1..44c8a230 100644 --- a/.github/workflows/test-coverage.yaml +++ b/.github/workflows/test-coverage.yaml @@ -77,7 +77,8 @@ jobs: install.packages(c("remotes")) remotes::install_deps(dependencies = TRUE) remotes::install_cran("covr") - remotes::install_version("BayesTools", "0.2.3") + #remotes::install_version("BayesTools", "0.2.3") + remotes::install_github("FBartos/BayesTools@v0.2.3") shell: Rscript {0} - name: Test coverage diff --git a/models/CustomEnsembles/Bem_update1.RDS b/models/CustomEnsembles/Bem_update1.RDS index 6b770769..7248e677 100644 Binary files a/models/CustomEnsembles/Bem_update1.RDS and b/models/CustomEnsembles/Bem_update1.RDS differ diff --git a/models/CustomEnsembles/Bem_update2.RDS b/models/CustomEnsembles/Bem_update2.RDS index 14ab0761..92366ef5 100644 Binary files a/models/CustomEnsembles/Bem_update2.RDS and b/models/CustomEnsembles/Bem_update2.RDS differ diff --git a/vignettes/CustomEnsembles.Rmd b/vignettes/CustomEnsembles.Rmd index bc0be460..27415c4f 100644 --- a/vignettes/CustomEnsembles.Rmd +++ b/vignettes/CustomEnsembles.Rmd @@ -29,6 +29,47 @@ if(.Platform$OS.type == "windows"){ } ``` +```{r include = FALSE, eval = FALSE} +# R package version updating +library(RoBMA) + +data("Bem2011", package = "RoBMA") +fit <- RoBMA(d = Bem2011$d, se = Bem2011$se, study_names = Bem2011$study, + priors_effect = NULL, priors_heterogeneity = NULL, priors_bias = NULL, + priors_effect_null = prior("spike", parameters = list(location = 0)), + priors_heterogeneity_null = prior("spike", parameters = list(location = 0)), + priors_bias_null = prior_none(), + seed = 1) + +fit <- update(fit, + prior_effect = prior("normal", parameters = list(mean = .15, sd = .10), truncation = list(lower = 0)), + prior_heterogeneity_null = prior("spike", parameters = list(location = 0)), + prior_bias_null = prior_none()) +saveRDS(fit, file = "../models/CustomEnsembles/Bem_update1.RDS") + +fit <- update(fit, + prior_effect = prior("normal", parameters = list(mean = .15, sd = .10), truncation = list(lower = 0)), + prior_heterogeneity = prior("invgamma", parameters = list(shape = 1, scale = .15)), + prior_bias_null = prior_none()) +fit <- update(fit, + prior_effect_null = prior("spike", parameters = list(location = 0)), + prior_heterogeneity_null = prior("spike", parameters = list(location = 0)), + prior_bias = prior_weightfunction("one.sided", parameters = list(alpha = c(1, 1), steps = c(0.05)))) +fit <- update(fit, + prior_effect_null = prior("spike", parameters = list(location = 0)), + prior_heterogeneity_null = prior("spike", parameters = list(location = 0)), + prior_bias = prior_weightfunction("one.sided", parameters = list(alpha = c(1, 1, 1), steps = c(0.05, 0.10)))) +fit <- update(fit, + prior_effect_null = prior("spike", parameters = list(location = 0)), + prior_heterogeneity_null = prior("spike", parameters = list(location = 0)), + prior_bias = prior_PET("Cauchy", parameters = list(0, 1), truncation = list(lower = 0))) +fit <- update(fit, + prior_effect_null = prior("spike", parameters = list(location = 0)), + prior_heterogeneity_null = prior("spike", parameters = list(location = 0)), + prior_bias = prior_PEESE("Cauchy", parameters = list(0, 5), truncation = list(lower = 0))) +saveRDS(fit, file = "../models/CustomEnsembles/Bem_update2.RDS") +``` + By default, the `RoBMA()` function specifies models as a combination of all supplied prior distributions (across null and alternative specification), with their prior model weights being equal to the product of prior distributions' weights. This results in the 36 meta-analytic models using the default settings [@bartos2021no]$^1$. In [another vignette](ReproducingBMA.html), we illustrated that RoBMA can be also utilized for reproducing Bayesian Model-Averaged Meta-Analysis (BMA) [@gronau2017bayesian; @gronau2020primer; @bartos2021bayesian]. However, the package was built as a framework for estimating highly customized meta-analytic model ensembles. Here, we are going to illustrate how to do exactly that (see @bartos2020adjusting for a tutorial paper on customizing the model ensemble with JASP). Please keep in mind that all models should be justified by theory. Furthermore, the models should be tested to make sure that the ensemble can perform as intended a priori to drawing inference from it. The following sections are only for illustrating the functionality of the package. We provide a completely discussion with the relevant sources in the Example section of @bartos2021no. diff --git a/vignettes/MedicineBMA.Rmd b/vignettes/MedicineBMA.Rmd index 578b4cfe..a385af00 100644 --- a/vignettes/MedicineBMA.Rmd +++ b/vignettes/MedicineBMA.Rmd @@ -35,6 +35,33 @@ fit_BMAb <- readRDS(file = "../models/MedicineBMA/fit_BMAb.RDS") fit_RoBMA <- readRDS(file = "../models/MedicineBMA/fit_RoBMA.RDS") ``` +```{r include = FALSE, eval = FALSE} +# R package version updating +library(RoBMA) + +data("Poulsen2006", package = "RoBMA") + +fit_BMA <- RoBMA(d = Poulsen2006$d, se = Poulsen2006$se, study_names = Poulsen2006$study, + priors_effect = prior_informed(name = "oral health", parameter = "effect", type = "smd"), + priors_heterogeneity = prior_informed(name = "oral health", parameter = "heterogeneity", type = "smd"), + priors_bias = NULL, + transformation = "cohens_d", seed = 1, parallel = TRUE) + +fit_BMAb <- RoBMA(d = Poulsen2006$d, se = Poulsen2006$se, study_names = Poulsen2006$study, + priors_effect = prior_informed(name = "oral health", parameter = "effect", type = "smd"), + priors_heterogeneity = prior_informed(name = "oral health", parameter = "heterogeneity", type = "smd"), + priors_bias = NULL, + seed = 1, parallel = TRUE) + +fit_RoBMA <- RoBMA(d = Poulsen2006$d, se = Poulsen2006$se, study_names = Poulsen2006$study, + priors_effect = prior_informed(name = "oral health", parameter = "effect", type = "smd"), + priors_heterogeneity = prior_informed(name = "oral health", parameter = "heterogeneity", type = "smd"), + seed = 1, parallel = TRUE) + +saveRDS(fit_BMA, file = "../models/MedicineBMA/fit_BMA.RDS") +saveRDS(fit_BMAb, file = "../models/MedicineBMA/fit_BMAb.RDS") +saveRDS(fit_RoBMA, file = "../models/MedicineBMA/fit_RoBMA.RDS") +``` Bayesian model-averaged meta-analysis allows researchers to seamlessly incorporate available prior information into the analysis [@gronau2017bayesian; @gronau2020primer; @bartos2021bayesian]. This vignette illustrates how to do this with an example from @bartos2021bayesian, who developed informed prior distributions for meta-analyses of continuous outcomes based on the Cochrane database of systematic reviews. Then, we extend the example by incorporating publication bias adjustment with robust Bayesian meta-analysis [@bartos2021no; @maier2020robust]. diff --git a/vignettes/ReproducingBMA.Rmd b/vignettes/ReproducingBMA.Rmd index d04ac87b..e2e04e02 100644 --- a/vignettes/ReproducingBMA.Rmd +++ b/vignettes/ReproducingBMA.Rmd @@ -36,6 +36,38 @@ fit_RoBMA_test <- readRDS(file = "../models/ReproducingBMA/PowerPoseTest.RDS") fit_RoBMA_est <- readRDS(file = "../models/ReproducingBMA/PowerPoseEst.RDS") ``` +```{r include = FALSE, eval = FALSE} +# R package version updating +library(RoBMA) + +data("power_pose", package = "metaBMA") + +fit_RoBMA_test <- RoBMA(d = power_pose$effectSize, se = power_pose$SE, study_names = power_pose$study, + priors_effect = prior( + distribution = "cauchy", + parameters = list(location = 0, scale = 1/sqrt(2)), + truncation = list(0, Inf)), + priors_heterogeneity = prior( + distribution = "invgamma", + parameters = list(shape = 1, scale = 0.15)), + priors_bias = NULL, + transformation = "cohens_d", seed = 1, parallel = TRUE) + +fit_RoBMA_est <- RoBMA(d = power_pose$effectSize, se = power_pose$SE, study_names = power_pose$study, + priors_effect = prior( + distribution = "cauchy", + parameters = list(location = 0, scale = 1/sqrt(2))), + priors_heterogeneity = prior( + distribution = "invgamma", + parameters = list(shape = 1, scale = 0.15)), + priors_bias = NULL, + priors_effect_null = NULL, + transformation = "cohens_d", seed = 2, parallel = TRUE) + +saveRDS(fit_RoBMA_test, file = "../models/ReproducingBMA/PowerPoseTest.RDS") +saveRDS(fit_RoBMA_est, file = "../models/ReproducingBMA/PowerPoseEst.RDS") +``` + By default, the package estimates an ensemble of 36 meta-analytic models and provides functions for convenient manipulation with the fitted object. However, it has been built in a way that it can be used as a framework for estimating any combination of meta-analytic models (or a single model). Here, we illustrate how to build a custom ensemble of meta-analytic models - specifically the same ensemble that is used in 'classical' Bayesian Model-Averaged Meta-Analysis [@gronau2017bayesian; @gronau2020primer; @bartos2021bayesian]. See [this vignette](CustomEnsembles.html) if you are interested in building more customized ensembles or @bartos2020adjusting for a tutorial on fitting (custom) models in JASP.