knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.width = 7,
  fig.height = 7,
  dev = "png",
  dev.args = list(type = "cairo-png")
)
library(barts)
set.seed(20210520)

Simulating a 2-arm trial: Experiment 1

Section 3.1.1 investigates the effect of different parameter combinations in Rule 1. With {barts}, we can easily define the parameter combinations under investigation:

rules <- list(
  a = rule_1(delta = 0.10, epsilon = 0.10),
  b = rule_1(delta = 0.10, epsilon = 0.05),
  c = rule_1(delta = 0.05, epsilon = 0.20)
)

# Investigated hypotheses
theta_null <- c(0.3, 0.3)
theta_alt <- c(0.3, 0.5)

To create a single realization of a study, we can use simulate_study():

study <- single_phase_study(n = 500, rule = rules[["a"]])
results <- simulate_study(study, a = 1, b = 1, theta = theta_alt)

The results track for each arm the prior parameters over time (a and b), the probability of being the best (p), and the activity state (I). Included is also the rule's next suggested allocation (A) , as well as the simulated data. The used allocation rule is stored in the "rule" attribute.

str(results)

The plot() method gives us a simple summary of a single phase's results:

plot(results)

For determining the operating characteristics of a set of design parameters, we need to simulate multiple realizations of the same study. We'll do that for the combinations of design parameters and hypotheses under investigation.

Simulating a 4-arm trial: Experiment 2



Orion-Corporation/barts documentation built on July 13, 2022, 10:23 p.m.