Skip to contents

Overview

The BayesianQDM package provides comprehensive methods for Bayesian quantitative decision-making in clinical trials. This vignette demonstrates the basic functionality for both binary and continuous endpoints.

Decision Framework

The package implements a three-zone decision framework:

  • Go: Sufficient evidence to proceed (high posterior probability)
  • NoGo: Insufficient evidence (low posterior probability)
  • Gray: Inconclusive evidence (intermediate probability)

Binary Endpoints

Basic Example

# Calculate decision probabilities for binary endpoint
result_binary <- BayesDecisionProbBinary(
  prob = 'posterior', 
  design = 'controlled', 
  theta.TV = 0.3, theta.MAV = 0.1,
  gamma1 = 0.8, gamma2 = 0.2,
  pi1 = c(0.3, 0.5, 0.7), 
  pi2 = rep(0.2, 3), 
  n1 = 15, n2 = 15,
  a1 = 0.5, a2 = 0.5, b1 = 0.5, b2 = 0.5,
  z = NULL, m1 = NULL, m2 = NULL,
  ne1 = NULL, ne2 = NULL, ye1 = NULL, ye2 = NULL, ae1 = NULL, ae2 = NULL
)

print(result_binary)
#>   pi1 pi2         Go      Gray         NoGo
#> 1 0.3 0.2 0.01578194 0.7624183 0.2217997893
#> 2 0.5 0.2 0.21141006 0.7643635 0.0242264031
#> 3 0.7 0.2 0.67440950 0.3248368 0.0007536922

Posterior Probability

# Calculate posterior probability
posterior_prob <- BayesPostPredBinary(
  prob = 'posterior', 
  design = 'controlled', 
  theta0 = 0.15,
  n1 = 12, n2 = 15, y1 = 7, y2 = 5, 
  a1 = 0.5, a2 = 0.5, b1 = 0.5, b2 = 0.5,
  m1 = NULL, m2 = NULL,
  ne1 = NULL, ne2 = NULL, ye1 = NULL, ye2 = NULL, ae1 = NULL, ae2 = NULL
)

cat("Posterior probability:", round(posterior_prob, 4))
#> Posterior probability: 0.6861

Continuous Endpoints

Basic Example

# Calculate decision probabilities for continuous endpoint  
result_continuous <- BayesDecisionProbContinuous(
  nsim = 50,  # Small nsim for vignette speed
  prob = 'posterior', 
  design = 'controlled', 
  prior = 'vague', 
  CalcMethod = 'WS',  # Fast method for vignette
  theta.TV = 1.5, theta.MAV = 0.5, theta.NULL = NULL,  # All required thresholds
  nMC = NULL, nINLAsample = NULL,  # Not needed for WS method
  gamma1 = 0.8, gamma2 = 0.3,
  n1 = 15, n2 = 15,
  m1 = NULL, m2 = NULL,  # Not needed for posterior probability
  kappa01 = NULL, kappa02 = NULL, nu01 = NULL, nu02 = NULL,  # Not needed for vague prior
  mu01 = NULL, mu02 = NULL, sigma01 = NULL, sigma02 = NULL,  # Not needed for vague prior
  mu1 = 3.0, mu2 = 1.2,
  sigma1 = 1.5, sigma2 = 1.5,
  r = NULL,  # Not needed for controlled design
  ne1 = NULL, ne2 = NULL, alpha01 = NULL, alpha02 = NULL,  # No external data
  seed = 123
)

print(result_continuous)
#>   mu1 mu2   Go NoGo Gray
#> 1   3 1.2 0.34    0 0.66

Posterior Probability

# Calculate posterior probability using WS method
posterior_prob_cont <- BayesPostPredContinuous(
  prob = 'posterior', 
  design = 'controlled', 
  prior = 'vague', 
  CalcMethod = 'WS',
  theta0 = 1.5, 
  n1 = 15, n2 = 15,
  bar.y1 = 4.2, bar.y2 = 2.1, 
  s1 = 1.5, s2 = 1.3
)

cat("Posterior probability:", round(posterior_prob_cont, 4))
#> Posterior probability: 0.8741

Calculation Methods

The package provides multiple calculation methods for continuous endpoints:

Method Comparison

# Compare different methods
sample_data <- list(
  bar.y1 = 4.2, bar.y2 = 2.1,
  s1 = 1.5, s2 = 1.3,
  n1 = 15, n2 = 15
)

theta0 <- 1.5

# Numerical Integration (most accurate)
prob_ni <- BayesPostPredContinuous(
  prob = 'posterior', design = 'controlled', prior = 'vague', CalcMethod = 'NI',
  theta0 = theta0, n1 = sample_data$n1, n2 = sample_data$n2,
  bar.y1 = sample_data$bar.y1, bar.y2 = sample_data$bar.y2, 
  s1 = sample_data$s1, s2 = sample_data$s2
)

# Welch-Satterthwaite (fast approximation)
prob_ws <- BayesPostPredContinuous(
  prob = 'posterior', design = 'controlled', prior = 'vague', CalcMethod = 'WS',
  theta0 = theta0, n1 = sample_data$n1, n2 = sample_data$n2,
  bar.y1 = sample_data$bar.y1, bar.y2 = sample_data$bar.y2, 
  s1 = sample_data$s1, s2 = sample_data$s2
)

cat("Method comparison for P(θ > 1.5):\n")
#> Method comparison for P(θ > 1.5):
cat("NI method:", round(prob_ni, 4), "\n")
#> NI method: 0.8656
cat("WS method:", round(prob_ws, 4), "\n")
#> WS method: 0.8741
cat("Difference:", round(abs(prob_ni - prob_ws), 4), "\n")
#> Difference: 0.0085

Study Designs

The package supports three study designs:

  1. Controlled Design: Standard two-arm randomized trial
  2. Uncontrolled Design: Single-arm with historical control
  3. External Control Design: Incorporating historical data via power priors

Prior Distributions

Binary Endpoints

  • Beta priors for response probabilities
  • Default: Beta(0.5, 0.5) for Jeffreys prior

Continuous Endpoints

  • Vague priors: Non-informative approach
  • Normal-Inverse-Chi-squared: Conjugate priors for incorporating prior knowledge

Summary

The BayesianQDM package provides:

  1. Flexible decision frameworks with customizable thresholds
  2. Multiple calculation methods balancing accuracy and speed
  3. Support for various designs including external data incorporation
  4. Comprehensive probability calculations for evidence-based decisions

For more detailed examples, see the binary-endpoints and continuous-endpoints vignettes.