Learn R Programming

tidyBF (version 0.3.0)

bf_meta: Bayes factor for random-effects meta-analysis

Description

Bayes factor for random-effects meta-analysis

Usage

bf_meta(
  data,
  d = prior("norm", c(mean = 0, sd = 0.3)),
  tau = prior("invgamma", c(shape = 1, scale = 0.15)),
  k = 2L,
  output = "results",
  caption = NULL,
  messages = TRUE,
  ...
)

Arguments

data

A dataframe. It must contain columns named estimate (effect sizes or outcomes) and std.error (corresponding standard errors). These two columns will be used for yi and sei arguments in metafor::rma (for parametric analysis) or metaplus::metaplus (for robust analysis).

d

prior distribution on the average effect size d. The prior probability density function is defined via prior.

tau

prior distribution on the between-study heterogeneity tau (i.e., the standard deviation of the study effect sizes dstudy in a random-effects meta-analysis. A (nonnegative) prior probability density function is defined via prior.

k

Number of digits after decimal point (should be an integer) (Default: k = 2L).

output

Can either be "null" (or "caption" or "H0" or "h0"), which will return expression with evidence in favor of the null hypothesis, or "alternative" (or "title" or "H1" or "h1"), which will return expression with evidence in favor of the alternative hypothesis, or "results", which will return a dataframe with results all the details).

caption

Text to display as caption (will be displayed on top of the Bayes Factor caption/message).

messages

Deprecated. Retained only for backward compatibility.

...

Arguments passed on to metaBMA::meta_random

labels

optional: character values with study labels. Can be a character vector or the quoted or unquoted name of the variable in data

rscale_contin

scale parameter of the JZS prior for the continuous covariates.

rscale_discrete

scale parameter of the JZS prior for discrete moderators.

centering

whether continuous moderators are centered.

logml

how to estimate the log-marginal likelihood: either by numerical integration ("integrate") or by bridge sampling using MCMC/Stan samples ("stan"). To obtain high precision with logml="stan", many MCMC samples are required (e.g., logml_iter=10000, warmup=1000).

summarize

how to estimate parameter summaries (mean, median, SD, etc.): Either by numerical integration (summarize = "integrate") or based on MCMC/Stan samples (summarize = "stan").

ci

probability for the credibility/highest-density intervals.

rel.tol

relative tolerance used for numerical integration using integrate. Use rel.tol=.Machine$double.eps for maximal precision (however, this might be slow).

logml_iter

number of iterations (per chain) from the posterior distribution of d and tau. The samples are used for computing the marginal likelihood of the random-effects model with bridge sampling (if logml="stan") and for obtaining parameter estimates (if summarize="stan"). Note that the argument iter=2000 controls the number of iterations for estimation of the random-effect parameters per study in random-effects meta-analysis.

silent_stan

whether to suppress the Stan progress bar.

Examples

Run this code
# NOT RUN {
# }
# NOT RUN {
# setup
set.seed(123)
library(metaBMA)

# creating a dataframe
(df <-
  structure(
    .Data = list(
      study = c("1", "2", "3", "4", "5"),
      estimate = c(
        0.382047603321706,
        0.780783111514665,
        0.425607573765058,
        0.558365541235078,
        0.956473848429961
      ),
      std.error = c(
        0.0465576338644502,
        0.0330218199731529,
        0.0362834986178494,
        0.0480571500648261,
        0.062215818388157
      )
    ),
    row.names = c(NA, -5L),
    class = c("tbl_df", "tbl", "data.frame")
  ))

# getting Bayes factor in favor of null hypothesis
bf_meta(
  data = df,
  k = 3,
  iter = 1500,
  messages = TRUE,
  # customizing analysis with additional arguments
  control = list(max_treedepth = 15)
)
# }
# NOT RUN {
# }

Run the code above in your browser using DataLab