pbayesdecisionprob2cont: Go/NoGo/Gray Decision Probabilities for Two Continuous...

View source: R/pbayesdecisionprob2cont.R

pbayesdecisionprob2contR Documentation

Go/NoGo/Gray Decision Probabilities for Two Continuous Endpoints

Description

Computes the operating characteristics (Go, NoGo, Gray, and optionally Miss probabilities) for a two-continuous-endpoint Bayesian Go/NoGo decision framework by Monte Carlo simulation over treatment scenarios.

Usage

pbayesdecisionprob2cont(
  nsim,
  prob,
  design,
  prior,
  GoRegions,
  NoGoRegions,
  gamma_go,
  gamma_nogo,
  theta_TV1 = NULL,
  theta_MAV1 = NULL,
  theta_TV2 = NULL,
  theta_MAV2 = NULL,
  theta_NULL1 = NULL,
  theta_NULL2 = NULL,
  n_t,
  n_c = NULL,
  m_t = NULL,
  m_c = NULL,
  mu_t,
  Sigma_t,
  mu_c = NULL,
  Sigma_c = NULL,
  kappa0_t = NULL,
  nu0_t = NULL,
  mu0_t = NULL,
  Lambda0_t = NULL,
  kappa0_c = NULL,
  nu0_c = NULL,
  mu0_c = NULL,
  Lambda0_c = NULL,
  r = NULL,
  ne_t = NULL,
  ne_c = NULL,
  alpha0e_t = NULL,
  alpha0e_c = NULL,
  bar_ye_t = NULL,
  bar_ye_c = NULL,
  se_t = NULL,
  se_c = NULL,
  nMC = NULL,
  CalcMethod = "MC",
  error_if_Miss = TRUE,
  Gray_inc_Miss = FALSE,
  seed
)

Arguments

nsim

A positive integer. Number of simulated datasets per scenario.

prob

A character string specifying the probability type. Must be 'posterior' or 'predictive'.

design

A character string specifying the trial design. Must be 'controlled', 'uncontrolled', or 'external'.

prior

A character string specifying the prior distribution. Must be 'vague' or 'N-Inv-Wishart'.

GoRegions

An integer vector specifying which of the nine posterior regions (R1–R9) or four predictive regions (R1–R4) constitute a Go decision. For prob = 'posterior', valid values are integers in 1–9; for prob = 'predictive', in 1–4. A common choice is GoRegions = 1 (both endpoints exceed TV or NULL for posterior/predictive, respectively).

NoGoRegions

An integer vector specifying which regions constitute a NoGo decision. A common choice is NoGoRegions = 9 (both endpoints below MAV) for posterior, or NoGoRegions = 4 for predictive. Must be disjoint from GoRegions.

gamma_go

A numeric scalar in (0, 1). Go threshold: a Go decision is made if P(\mathrm{GoRegions}) \ge \gamma_1.

gamma_nogo

A numeric scalar in (0, 1). NoGo threshold: a NoGo decision is made if P(\mathrm{NoGoRegions}) \ge \gamma_2. No ordering constraint on gamma_go and gamma_nogo is imposed; their combination determines the frequency of Miss outcomes.

theta_TV1

A numeric scalar giving the target value (TV) threshold for Endpoint 1. Required when prob = 'posterior'; must satisfy theta_TV1 > theta_MAV1. Set to NULL when prob = 'predictive'.

theta_MAV1

A numeric scalar giving the minimum acceptable value (MAV) threshold for Endpoint 1. Required when prob = 'posterior'; must satisfy theta_TV1 > theta_MAV1. Set to NULL when prob = 'predictive'.

theta_TV2

A numeric scalar giving the target value (TV) threshold for Endpoint 2. Required when prob = 'posterior'; must satisfy theta_TV2 > theta_MAV2. Set to NULL when prob = 'predictive'.

theta_MAV2

A numeric scalar giving the minimum acceptable value (MAV) threshold for Endpoint 2. Required when prob = 'posterior'; must satisfy theta_TV2 > theta_MAV2. Set to NULL when prob = 'predictive'.

theta_NULL1

A numeric scalar giving the null hypothesis threshold for Endpoint 1. Required when prob = 'predictive'; set to NULL when prob = 'posterior'.

theta_NULL2

A numeric scalar giving the null hypothesis threshold for Endpoint 2. Required when prob = 'predictive'; set to NULL when prob = 'posterior'.

n_t

A positive integer giving the number of patients in the treatment group in the proof-of-concept (PoC) trial.

n_c

A positive integer giving the number of patients in the control group in the PoC trial. For design = 'uncontrolled', this is the hypothetical control sample size (required for consistency with other designs).

m_t

A positive integer giving the number of patients in the treatment group for the future trial. Required when prob = 'predictive'; otherwise set to NULL.

m_c

A positive integer giving the number of patients in the control group for the future trial. Required when prob = 'predictive'; otherwise set to NULL.

mu_t

Numeric matrix with 2 columns. Each row gives the true treatment mean vector for one scenario. A length-2 vector is coerced to a 1-row matrix.

Sigma_t

A 2x2 positive-definite matrix. True treatment covariance.

mu_c

Numeric matrix with 2 columns or a length-2 vector. True control (or hypothetical control) mean vector(s).

Sigma_c

A 2x2 positive-definite matrix. True control covariance.

kappa0_t

A positive numeric scalar giving the NIW prior concentration parameter for the treatment group. Required when prior = 'N-Inv-Wishart'; otherwise set to NULL.

nu0_t

A numeric scalar giving the NIW prior degrees of freedom for the treatment group. Must be greater than 3. Required when prior = 'N-Inv-Wishart'; otherwise set to NULL.

mu0_t

A numeric vector of length 2 giving the NIW prior mean for the treatment group. Required when prior = 'N-Inv-Wishart'; otherwise set to NULL.

Lambda0_t

A 2x2 positive-definite numeric matrix giving the NIW prior scale matrix for the treatment group. Required when prior = 'N-Inv-Wishart'; otherwise set to NULL.

kappa0_c

A positive numeric scalar giving the NIW prior concentration parameter for the control group. Required when prior = 'N-Inv-Wishart' and design != 'uncontrolled'; otherwise set to NULL.

nu0_c

A numeric scalar giving the NIW prior degrees of freedom for the control group. Must be greater than 3. Required when prior = 'N-Inv-Wishart' and design != 'uncontrolled'; otherwise set to NULL.

mu0_c

A numeric vector of length 2 giving the NIW prior mean for the control group, or the hypothetical control location when design = 'uncontrolled'. Required when prior = 'N-Inv-Wishart'; otherwise set to NULL.

Lambda0_c

A 2x2 positive-definite numeric matrix giving the NIW prior scale matrix for the control group. Required when prior = 'N-Inv-Wishart' and design != 'uncontrolled'; otherwise set to NULL.

r

A positive numeric scalar giving the variance scaling factor for the hypothetical control distribution. Required when design = 'uncontrolled'; otherwise set to NULL.

ne_t

A positive integer giving the external treatment group sample size. Required when design = 'external' and external treatment data are used; otherwise set to NULL.

ne_c

A positive integer giving the external control group sample size. Required when design = 'external' and external control data are used; otherwise set to NULL.

alpha0e_t

A numeric scalar in (0, 1] giving the power prior weight for the external treatment data. Required when external treatment data are used; otherwise set to NULL.

alpha0e_c

A numeric scalar in (0, 1] giving the power prior weight for the external control data. Required when external control data are used; otherwise set to NULL.

bar_ye_t

A numeric vector of length 2 giving the external treatment group sample mean. Required when external treatment data are used; otherwise set to NULL.

bar_ye_c

A numeric vector of length 2 giving the external control group sample mean. Required when external control data are used; otherwise set to NULL.

se_t

A 2x2 numeric matrix giving the external treatment group sum-of-squares matrix. Required when external treatment data are used; otherwise set to NULL.

se_c

A 2x2 numeric matrix giving the external control group sum-of-squares matrix. Required when external control data are used; otherwise set to NULL.

nMC

A positive integer giving the number of Monte Carlo draws used to estimate region probabilities. Default is 10000. Required when CalcMethod = 'MC'. May be set to NULL when CalcMethod = 'MM' and \nu_k > 4 (the MM method uses mvtnorm::pmvt analytically); if CalcMethod = 'MM' but \nu_k \le 4 causes a fallback to MC, nMC must be a positive integer.

CalcMethod

A character string specifying the computation method. Must be 'MC' (Monte Carlo, default) or 'MM' (Moment-Matching via mvtnorm::pmvt). When CalcMethod = 'MM' and \nu_k \le 4, a warning is issued and the function falls back to CalcMethod = 'MC'.

error_if_Miss

Logical. If TRUE (default), the function stops with an error when positive Miss probability is obtained. If FALSE, Miss probability is handled according to Gray_inc_Miss.

Gray_inc_Miss

Logical. If TRUE, Miss probability is included in Gray probability. If FALSE (default), Miss probability is reported as a separate column. Active only when error_if_Miss = FALSE.

seed

A single numeric value. Seed for reproducible random number generation.

Details

The function follows the same structure as pbayesdecisionprob1cont:

  1. For each scenario s, nsim datasets are simulated by generating treatment (and control) observations from N_2(\mu_k^{(s)}, \Sigma_k). To minimise overhead, raw standardised residuals are generated once (scenario- invariant) and shifted by the scenario mean.

  2. All nsim simulated sufficient statistics (\bar{y}_{1,i}, S_{1,i}) (and (\bar{y}_{2,i}, S_{2,i}) for controlled/external designs) are passed to pbayespostpred2cont in a single vectorised call, returning an nsim \times n_{\rm regions} matrix of region probabilities.

  3. Go/NoGo/Miss probabilities are obtained as the column means of indicator matrices derived from the region probability matrix.

Value

A data frame of class c("pbayesdecisionprob2cont", "data.frame") with columns for the scenario parameters and Go, NoGo, Gray (and optionally Miss) probabilities. All input parameters are attached as attributes.

Examples

# Example 1: Controlled design, posterior probability, vague prior
Sigma <- matrix(c(4.0, 0.8, 0.8, 1.0), 2, 2)
pbayesdecisionprob2cont(
  nsim = 100L, prob = 'posterior', design = 'controlled',
  prior = 'vague',
  GoRegions = 1L, NoGoRegions = 9L,
  gamma_go = 0.8, gamma_nogo = 0.8,
  theta_TV1 = 1.5, theta_MAV1 = 0.5,
  theta_TV2 = 1.0, theta_MAV2 = 0.3,
  theta_NULL1 = NULL, theta_NULL2 = NULL,
  n_t = 20L, n_c = 20L, m_t = NULL, m_c = NULL,
  mu_t = rbind(c(1.0, 0.5), c(2.5, 1.5), c(4.0, 2.5)),
  Sigma_t = Sigma,
  mu_c = rbind(c(0.0, 0.0), c(0.0, 0.0), c(0.0, 0.0)),
  Sigma_c = Sigma,
  kappa0_t = NULL, nu0_t = NULL, mu0_t = NULL, Lambda0_t = NULL,
  kappa0_c = NULL, nu0_c = NULL, mu0_c = NULL, Lambda0_c = NULL,
  r = NULL,
  ne_t = NULL, ne_c = NULL, alpha0e_t = NULL, alpha0e_c = NULL,
  bar_ye_t = NULL, bar_ye_c = NULL, se_t = NULL, se_c = NULL,
  nMC = 500L, CalcMethod = 'MC',
  error_if_Miss = TRUE, Gray_inc_Miss = FALSE, seed = 1L
)

# Example 2: Uncontrolled design, posterior probability, NIW prior
Sigma <- matrix(c(4.0, 0.8, 0.8, 1.0), 2, 2)
L0    <- matrix(c(8.0, 0.0, 0.0, 2.0), 2, 2)
pbayesdecisionprob2cont(
  nsim = 100L, prob = 'posterior', design = 'uncontrolled',
  prior = 'N-Inv-Wishart',
  GoRegions = 1L, NoGoRegions = 9L,
  gamma_go = 0.8, gamma_nogo = 0.8,
  theta_TV1 = 1.5, theta_MAV1 = 0.5,
  theta_TV2 = 1.0, theta_MAV2 = 0.3,
  theta_NULL1 = NULL, theta_NULL2 = NULL,
  n_t = 20L, n_c = NULL, m_t = NULL, m_c = NULL,
  mu_t = rbind(c(1.0, 0.5), c(2.5, 1.5), c(4.0, 2.5)),
  Sigma_t = Sigma,
  mu_c = rbind(c(0.0, 0.0), c(0.0, 0.0), c(0.0, 0.0)),
  Sigma_c = Sigma,
  kappa0_t = 2.0, nu0_t = 5.0, mu0_t = c(2.0, 1.0), Lambda0_t = L0,
  kappa0_c = NULL, nu0_c = NULL, mu0_c = c(0.0, 0.0), Lambda0_c = NULL,
  r = 1.0,
  ne_t = NULL, ne_c = NULL, alpha0e_t = NULL, alpha0e_c = NULL,
  bar_ye_t = NULL, bar_ye_c = NULL, se_t = NULL, se_c = NULL,
  nMC = 500L, CalcMethod = 'MC',
  error_if_Miss = TRUE, Gray_inc_Miss = FALSE, seed = 3L
)

# Example 3: External design (control only), posterior probability, NIW prior
Sigma  <- matrix(c(4.0, 0.8, 0.8, 1.0), 2, 2)
L0     <- matrix(c(8.0, 0.0, 0.0, 2.0), 2, 2)
se_mat <- matrix(c(7.0, 1.2, 1.2, 1.8), 2, 2)
pbayesdecisionprob2cont(
  nsim = 100L, prob = 'posterior', design = 'external',
  prior = 'N-Inv-Wishart',
  GoRegions = 1L, NoGoRegions = 9L,
  gamma_go = 0.8, gamma_nogo = 0.8,
  theta_TV1 = 1.5, theta_MAV1 = 0.5,
  theta_TV2 = 1.0, theta_MAV2 = 0.3,
  theta_NULL1 = NULL, theta_NULL2 = NULL,
  n_t = 20L, n_c = 20L, m_t = NULL, m_c = NULL,
  mu_t = rbind(c(1.0, 0.5), c(2.5, 1.5), c(4.0, 2.5)),
  Sigma_t = Sigma,
  mu_c = rbind(c(0.0, 0.0), c(0.0, 0.0), c(0.0, 0.0)),
  Sigma_c = Sigma,
  kappa0_t = 2.0, nu0_t = 5.0, mu0_t = c(2.0, 1.0), Lambda0_t = L0,
  kappa0_c = 2.0, nu0_c = 5.0, mu0_c = c(0.0, 0.0), Lambda0_c = L0,
  r = NULL,
  ne_t = NULL, ne_c = 15L, alpha0e_t = NULL, alpha0e_c = 0.5,
  bar_ye_t = NULL, bar_ye_c = c(0.2, 0.1), se_t = NULL, se_c = se_mat,
  nMC = 500L, CalcMethod = 'MC',
  error_if_Miss = TRUE, Gray_inc_Miss = FALSE, seed = 5L
)

# Example 4: Controlled design, predictive probability, NIW prior
Sigma <- matrix(c(4.0, 0.8, 0.8, 1.0), 2, 2)
L0    <- matrix(c(8.0, 0.0, 0.0, 2.0), 2, 2)
pbayesdecisionprob2cont(
  nsim = 100L, prob = 'predictive', design = 'controlled',
  prior = 'N-Inv-Wishart',
  GoRegions = 1L, NoGoRegions = 4L,
  gamma_go = 0.8, gamma_nogo = 0.8,
  theta_TV1 = NULL, theta_MAV1 = NULL,
  theta_TV2 = NULL, theta_MAV2 = NULL,
  theta_NULL1 = 0.5, theta_NULL2 = 0.3,
  n_t = 20L, n_c = 20L, m_t = 60L, m_c = 60L,
  mu_t = rbind(c(1.0, 0.5), c(2.5, 1.5), c(4.0, 2.5)),
  Sigma_t = Sigma,
  mu_c = rbind(c(0.0, 0.0), c(0.0, 0.0), c(0.0, 0.0)),
  Sigma_c = Sigma,
  kappa0_t = 2.0, nu0_t = 5.0, mu0_t = c(2.0, 1.0), Lambda0_t = L0,
  kappa0_c = 2.0, nu0_c = 5.0, mu0_c = c(0.0, 0.0), Lambda0_c = L0,
  r = NULL,
  ne_t = NULL, ne_c = NULL, alpha0e_t = NULL, alpha0e_c = NULL,
  bar_ye_t = NULL, bar_ye_c = NULL, se_t = NULL, se_c = NULL,
  nMC = 500L, CalcMethod = 'MC',
  error_if_Miss = TRUE, Gray_inc_Miss = FALSE, seed = 4L
)

# Example 5: Uncontrolled design, predictive probability, vague prior
Sigma <- matrix(c(4.0, 0.8, 0.8, 1.0), 2, 2)
pbayesdecisionprob2cont(
  nsim = 100L, prob = 'predictive', design = 'uncontrolled',
  prior = 'vague',
  GoRegions = 1L, NoGoRegions = 4L,
  gamma_go = 0.8, gamma_nogo = 0.8,
  theta_TV1 = NULL, theta_MAV1 = NULL,
  theta_TV2 = NULL, theta_MAV2 = NULL,
  theta_NULL1 = 0.5, theta_NULL2 = 0.3,
  n_t = 20L, n_c = NULL, m_t = 60L, m_c = 60L,
  mu_t = rbind(c(1.0, 0.5), c(2.5, 1.5), c(4.0, 2.5)),
  Sigma_t = Sigma,
  mu_c = NULL,
  Sigma_c = NULL,
  kappa0_t = NULL, nu0_t = NULL, mu0_t = NULL, Lambda0_t = NULL,
  kappa0_c = NULL, nu0_c = NULL, mu0_c = c(0.0, 0.0), Lambda0_c = NULL,
  r = 1.0,
  ne_t = NULL, ne_c = NULL, alpha0e_t = NULL, alpha0e_c = NULL,
  bar_ye_t = NULL, bar_ye_c = NULL, se_t = NULL, se_c = NULL,
  nMC = 500L, CalcMethod = 'MC',
  error_if_Miss = TRUE, Gray_inc_Miss = FALSE, seed = 8L
)

# Example 6: External design (control only), predictive probability, NIW prior
Sigma  <- matrix(c(4.0, 0.8, 0.8, 1.0), 2, 2)
L0     <- matrix(c(8.0, 0.0, 0.0, 2.0), 2, 2)
se_mat <- matrix(c(7.0, 1.2, 1.2, 1.8), 2, 2)
pbayesdecisionprob2cont(
  nsim = 100L, prob = 'predictive', design = 'external',
  prior = 'N-Inv-Wishart',
  GoRegions = 1L, NoGoRegions = 4L,
  gamma_go = 0.8, gamma_nogo = 0.8,
  theta_TV1 = NULL, theta_MAV1 = NULL,
  theta_TV2 = NULL, theta_MAV2 = NULL,
  theta_NULL1 = 0.5, theta_NULL2 = 0.3,
  n_t = 20L, n_c = 20L, m_t = 60L, m_c = 60L,
  mu_t = rbind(c(1.0, 0.5), c(2.5, 1.5), c(4.0, 2.5)),
  Sigma_t = Sigma,
  mu_c = rbind(c(0.0, 0.0), c(0.0, 0.0), c(0.0, 0.0)),
  Sigma_c = Sigma,
  kappa0_t = 2.0, nu0_t = 5.0, mu0_t = c(2.0, 1.0), Lambda0_t = L0,
  kappa0_c = 2.0, nu0_c = 5.0, mu0_c = c(0.0, 0.0), Lambda0_c = L0,
  r = NULL,
  ne_t = NULL, ne_c = 15L, alpha0e_t = NULL, alpha0e_c = 0.5,
  bar_ye_t = NULL, bar_ye_c = c(0.2, 0.1), se_t = NULL, se_c = se_mat,
  nMC = 500L, CalcMethod = 'MC',
  error_if_Miss = TRUE, Gray_inc_Miss = FALSE, seed = 9L
)


BayesianQDM documentation built on April 22, 2026, 1:09 a.m.