## ----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     = "v13-metafor-parity-glmm",
  objects  = c("fit1_brma"),
  packages = c("metafor", "metadat")
)

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

## ----load-models, include = [encoded data, 9970 characters]
library("metafor")
library("RoBMA")

data("dat.bcg", package = "metadat")

vignette_cache_load(cached_fits)

## ----precompute-models, include = FALSE, eval = [encoded data, 9950 characters]
# library("metafor")
# library("RoBMA")
# 
# data("dat.bcg", package = "metadat")
# 
# fit1_brma <- brma.glmm(
#   ai = tpos, bi = tneg, ci = cpos, di = cneg, measure = "OR",
#   data = dat.bcg, seed = 1
# )
# 
# vignette_cache_save(cached_fits)

## [encoded data, 9997 characters]
data("dat.bcg", package = "metadat")
head(dat.bcg)

## [encoded data, 9997 characters]
fit1_metafor <- metafor::rma.glmm(
  ai = tpos, bi = tneg, ci = cpos, di = cneg, measure = "OR", 
  model = "UM.FS", data = dat.bcg
)
fit1_metafor

## ----fit1-brma, eval = [encoded data, 9975 characters]
# fit1_brma <- brma.glmm(
#   ai = tpos, bi = tneg, ci = cpos, di = cneg, measure = "OR",
#   data = dat.bcg, seed = 1
# )

## [encoded data, 9997 characters]
summary(fit1_brma, include_mcmc_diagnostics = FALSE)

## [encoded data, 9997 characters]
pooled_effect(fit1_brma, transform = "EXP")

