## ----vignette-nowrap-options, include = FALSE, eval = [encoded data, 9944 characters]
options(width = 10000)

## ----setup, include = [encoded data, 9976 characters]
source("vignette-cache.R", local = knitr::knit_global())

cached_fits <- vignette_cache(
  name    = "v34-bma-norm-medicine",
  objects = c("fit_BMA", "fit_RoBMA")
)

knitr::opts_chunk$set(
  collapse   = TRUE,
  comment    = "#>",
  eval       = vignette_cache_eval(cached_fits),
  message    = FALSE,
  warning    = FALSE,
  dev        = "png",
  fig.retina = 3
)
if (.Platform$OS.type == "windows") {
  knitr::opts_chunk$set(dev.args = list(type = "cairo"))
}

## ----include = [encoded data, 9983 characters]
library(RoBMA)

data("Poulsen2006", package = "RoBMA")

vignette_cache_load(cached_fits)

## ----include = FALSE, eval = [encoded data, 9969 characters]
# # R package version updating
# library(RoBMA)
# 
# data("Poulsen2006", package = "RoBMA")
# 
# fit_BMA <- BMA(
#   yi = d, sei = se, measure = "SMD",
#   prior_informed_field    = "medicine",
#   prior_informed_subfield = "Oral Health",
#   data = Poulsen2006, slab = study,
#   seed = 1, parallel = TRUE
# )
# 
# fit_RoBMA <- RoBMA(
#   yi = d, sei = se, measure = "SMD",
#   prior_informed_field    = "medicine",
#   prior_informed_subfield = "Oral Health",
#   data = Poulsen2006, slab = study,
#   seed = 1, parallel = TRUE
# )
# 
# vignette_cache_save(cached_fits)

## [encoded data, 9997 characters]
library(RoBMA)

data("Poulsen2006", package = "RoBMA")
Poulsen2006

## [encoded data, 9997 characters]
summary(fit_BMA, conditional = TRUE, include_mcmc_diagnostics = FALSE)

## [encoded data, 9997 characters]
pooled_effect(fit_BMA, conditional = TRUE)
pooled_heterogeneity(fit_BMA, conditional = TRUE)

## ----fig_mu_BMA, fig.width = 6, fig.height = 4, out.width = "75%", fig.align = "center"[encoded data, 9911 characters]
par(mar = c(4, 4, 0, 4))
plot(fit_BMA, parameter = "mu", prior = TRUE, xlim = c(-2, 2), lwd = 2)

## ----fig_mu_BMA_cond, fig.width = 6, fig.height = 4, out.width = "75%", fig.align = "center"[encoded data, 9906 characters]
par(mar = c(4, 4, 0, 4))
plot(fit_BMA, parameter = "mu", prior = TRUE, conditional = TRUE, xlim = c(-2, 2), lwd = 2)

## [encoded data, 9997 characters]
summary(fit_RoBMA, conditional = TRUE, include_mcmc_diagnostics = FALSE)

## [encoded data, 9997 characters]
pooled_effect(fit_BMA, conditional = TRUE)
pooled_effect(fit_RoBMA, conditional = TRUE)

## ----fig_mu_RoBMA_cond, fig.width = 6, fig.height = 4, out.width = "75%", fig.align = "center"[encoded data, 9904 characters]
par(mar = c(4, 4, 0, 4))
plot(fit_RoBMA, parameter = "mu", prior = TRUE, conditional = TRUE, xlim = c(-2, 2), lwd = 2)

