multiArmAnalysis {epts}R Documentation

Bayesian or Frequentist Analysis with Forest Plot Comparison for Multi-Arm Trial Designs

Description

This function fits Bayesian or frequentist and producing a forest plot across multiple intervention groups for cluster randomized trials (CRT), multisite trials (MST) or simple randomized trials (SRT).

Usage

multiArmAnalysis(
  method = "crtBayes",
  data,
  outcome = "posttest",
  interventions = "interventions",
  Random = "schools",
  Nsim = 10000,
  Threshold = 0.05,
  FREQoption = "Default",
  nPerm = NULL,
  nBoot = NULL,
  bootType = NULL,
  continuous_covariates = NULL,
  categorical_covariates = NULL,
  maintitle = NULL,
  xlabel = NULL,
  ylabel = NULL,
  vlinecolor = "black",
  intlabels = NULL,
  intcolors = NULL
)

Arguments

method

The model fitting method. Should be specified as a character string. Choices are:

  • "crtBayes": Bayesian analysis of cluster randomised trials using vague priors.

  • "crtFREQ": Analysis of cluster randomised trials using a multilevel model under a frequentist setting.

  • "mstBayes": Bayesian analysis of multisite randomised trials using vague priors.

  • "mstFREQ": Analysis of multisite randomised trials using a multilevel model under a frequentist setting.

  • "srtBayes": Bayesian analysis of simple randomised trials using vague priors.

  • "srtFREQ": Analysis of simple randomised trials under a frequentist setting.

data

A data frame containing the variables including outcome, predictors, the clustering variable, and the intervention.

outcome

The name of the outcome (post-test) variable.

interventions

A string specifying the intervention variable.

Random

The name of the clustering variable (e.g., schools or sites) for CRT and MST designs.

Nsim

Number of MCMC iterations to be performed for Bayesian analysis. A minimum of 10,000 is recommended to ensure convergence.

Threshold

The effect size threshold for posterior computation for Bayesian analysis (default = 0.05).

FREQoption

The option for frequentist methods. Choices are "Default", "Permutation", or "Bootstrap".

nPerm

The number of permutations required to generate a permutated p-value.

nBoot

The number of bootstraps required to generate bootstrap confidence intervals.

bootType

method of bootstrapping including case re-sampling at student level "case(1)",case re-sampling at school level "case(2)", case re-sampling at both levels "case(1,2)" and residual bootstrapping using "residual". If not provided, default will be case re-sampling at student level.

continuous_covariates

A character vector specifying the names of continuous covariates.

categorical_covariates

A character vector specifying the names of categorical covariates (converted to factors).

maintitle

main title for the plot.

xlabel

Label for the x-axis.

ylabel

Label for the y-axis.

vlinecolor

Color of the vertical reference line (default = "black").

intlabels

Optional custom intervention labels for the plot.

intcolors

Optional intervention colors for the plot.

Details

This function loops through each intervention, fits the requested statistical model, stores the results, and forest plot visualization for easy comparison. It allows flexible customization for plotting aesthetics.

Value

A ggplot object showing intervention effect sizes and their confidence intervals.

See Also

Functions from the eefAnalytics package: crtBayes, crtFREQ, mstBayes, mstFREQ, srtBayes, srtFREQ

Examples


### Bayesian analysis of cluster randomised trials ###
data(crt4armSimData)
multiArmAnalysis(method = "crtBayes", data = crt4armSimData, outcome = "posttest", 
interventions = "interventions", Random = "schools", Nsim = 10000, Threshold = 0.05, 
continuous_covariates = c("pretest"), categorical_covariates = c("gender", "ethnicity"),
intlabels = c("Intervention A", "Intervention B", "Intervention C"),
maintitle = "Forest plot of comparison of effect sizes", xlabel = "Hedges'g", 
ylabel = "Interventions", vlinecolor = "black")

###MLM analysis of multisite trials with residual bootstrap confidence intervals ###
data(mst4armSimData)
multiArmAnalysis(method = "mstFREQ", data = mst4armSimData, outcome = "posttest",
interventions = "interventions", Random = "schools", nBoot = 1000, bootType="residual",
continuous_covariates = c("pretest"), categorical_covariates = c("gender", "ethnicity"),
intlabels = c("Intervention A", "Intervention B", "Intervention C"),
intcolors = c("Intervention A" = "blue", "Intervention B" = "green", "Intervention C" = "red"),
maintitle = "Forest plot of comparison of effect sizes ", xlabel = "Hedges'g",
ylabel = "Interventions", vlinecolor = "black")

###MLM analysis of multisite trials with permutation p-value###
data(mst4armSimData)
multiArmAnalysis(method = "mstFREQ", data = mst4armSimData, outcome = "posttest", 
interventions = "interventions", Random = "schools", nPerm = 1000, 
continuous_covariates = c("pretest"), categorical_covariates = c("gender", "ethnicity"), 
intlabels = c("Intervention A", "Intervention B", "Intervention C"),
intcolors = c("Intervention A" = "blue", "Intervention B" = "green", "Intervention C" = "red"), 
maintitle = "Forest plot of comparison of effect sizes ",
xlabel = "Hedges'g", ylabel = "Interventions", vlinecolor = "black")


###Bayesian analysis of simple randomised trials###
data(srt4armSimData)
multiArmAnalysis(method = "srtBayes", data = srt4armSimData, outcome = "posttest",
interventions = "interventions", Random = "schools", Nsim = 10000, Threshold = 0.05, 
continuous_covariates = c("pretest"), categorical_covariates = c("gender", "ethnicity"),
intlabels = c("Int A", "Int B", "Int C"),
intcolors = c("Int A" = "#1F77B4", "Int B" = "#2CA02C", "Int C" = "#D62728"),
maintitle = "Forest plot of comparison of effect sizes ", xlabel = "Hedges'g", 
ylabel = "Interventions", vlinecolor = "black")



[Package epts version 1.2.2 Index]