getgamma2bin: Find Optimal Go/NoGo Thresholds for Two Binary Endpoints

View source: R/getgamma2bin.R

getgamma2binR Documentation

Find Optimal Go/NoGo Thresholds for Two Binary Endpoints

Description

Computes the optimal Go threshold \gamma_{\mathrm{go}} and NoGo threshold \gamma_{\mathrm{nogo}} for two binary endpoints by searching over a two-dimensional grid of candidate value pairs. The two thresholds are calibrated independently under separate scenarios:

  • \gamma_{\mathrm{go}} is the smallest value in gamma_go_grid such that the worst-case marginal Go probability over all \gamma_{\mathrm{nogo}} in gamma_nogo_grid is strictly less than target_go under the Go-calibration scenario (pi_t1_go, pi_t2_go, rho_t_go, pi_c1_go, pi_c2_go, rho_c_go); typically the Null scenario.

  • \gamma_{\mathrm{nogo}} is the smallest value in gamma_nogo_grid such that the worst-case marginal NoGo probability over all \gamma_{\mathrm{go}} in gamma_go_grid is strictly less than target_nogo under the NoGo-calibration scenario (pi_t1_nogo, pi_t2_nogo, rho_t_nogo, pi_c1_nogo, pi_c2_nogo, rho_c_nogo); typically the Alternative scenario.

Usage

getgamma2bin(
  prob = "posterior",
  design = "controlled",
  GoRegions,
  NoGoRegions,
  pi_t1_go,
  pi_t2_go,
  rho_t_go,
  pi_c1_go = NULL,
  pi_c2_go = NULL,
  rho_c_go = NULL,
  pi_t1_nogo,
  pi_t2_nogo,
  rho_t_nogo,
  pi_c1_nogo = NULL,
  pi_c2_nogo = NULL,
  rho_c_nogo = NULL,
  target_go,
  target_nogo,
  n_t,
  n_c,
  a_t_00,
  a_t_01,
  a_t_10,
  a_t_11,
  a_c_00,
  a_c_01,
  a_c_10,
  a_c_11,
  theta_TV1 = NULL,
  theta_MAV1 = NULL,
  theta_TV2 = NULL,
  theta_MAV2 = NULL,
  theta_NULL1 = NULL,
  theta_NULL2 = NULL,
  m_t = NULL,
  m_c = NULL,
  z00 = NULL,
  z01 = NULL,
  z10 = NULL,
  z11 = NULL,
  xe_t_00 = NULL,
  xe_t_01 = NULL,
  xe_t_10 = NULL,
  xe_t_11 = NULL,
  xe_c_00 = NULL,
  xe_c_01 = NULL,
  xe_c_10 = NULL,
  xe_c_11 = NULL,
  alpha0e_t = NULL,
  alpha0e_c = NULL,
  nMC = 1000L,
  gamma_go_grid = seq(0.01, 0.99, by = 0.01),
  gamma_nogo_grid = seq(0.01, 0.99, by = 0.01)
)

Arguments

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'.

GoRegions

An integer vector of region indices (subset of 1:9 for prob = 'posterior' or 1:4 for prob = 'predictive') that constitute the Go region.

NoGoRegions

An integer vector of region indices that constitute the NoGo region. Must be disjoint from GoRegions.

pi_t1_go

A numeric scalar in (0, 1) giving the true treatment response probability for Endpoint 1 under the Go-calibration scenario (typically Null).

pi_t2_go

A numeric scalar in (0, 1) giving the true treatment response probability for Endpoint 2 under the Go-calibration scenario.

rho_t_go

A numeric scalar giving the within-group correlation in the treatment group under the Go-calibration scenario.

pi_c1_go

A numeric scalar in (0, 1) giving the true control response probability for Endpoint 1 under the Go-calibration scenario. Required for design = 'controlled' or 'external'; set to NULL for design = 'uncontrolled'.

pi_c2_go

A numeric scalar in (0, 1) giving the true control response probability for Endpoint 2 under the Go-calibration scenario. Required for design = 'controlled' or 'external'; set to NULL for design = 'uncontrolled'.

rho_c_go

A numeric scalar giving the within-group correlation in the control group under the Go-calibration scenario. Required for design = 'controlled' or 'external'; set to NULL for design = 'uncontrolled'.

pi_t1_nogo

A numeric scalar in (0, 1) giving the true treatment response probability for Endpoint 1 under the NoGo-calibration scenario (typically Alternative).

pi_t2_nogo

A numeric scalar in (0, 1) giving the true treatment response probability for Endpoint 2 under the NoGo-calibration scenario.

rho_t_nogo

A numeric scalar giving the within-group correlation in the treatment group under the NoGo-calibration scenario.

pi_c1_nogo

A numeric scalar in (0, 1) giving the true control response probability for Endpoint 1 under the NoGo-calibration scenario. Required for design = 'controlled' or 'external'; set to NULL for design = 'uncontrolled'.

pi_c2_nogo

A numeric scalar in (0, 1) giving the true control response probability for Endpoint 2 under the NoGo-calibration scenario. Required for design = 'controlled' or 'external'; set to NULL for design = 'uncontrolled'.

rho_c_nogo

A numeric scalar giving the within-group correlation in the control group under the NoGo-calibration scenario. Required for design = 'controlled' or 'external'; set to NULL for design = 'uncontrolled'.

target_go

A numeric scalar in (0, 1) giving the upper bound on the worst-case marginal Go probability under the Go-calibration scenario. The optimal \gamma_{\mathrm{go}} is the smallest grid value satisfying the constraint.

target_nogo

A numeric scalar in (0, 1) giving the upper bound on the worst-case marginal NoGo probability under the NoGo-calibration scenario. The optimal \gamma_{\mathrm{nogo}} is the smallest grid value satisfying the constraint.

n_t

A positive integer giving the number of patients in the treatment group in the PoC trial.

n_c

A positive integer giving the number of patients in the control group in the PoC trial.

a_t_00

A positive numeric scalar giving the Dirichlet prior parameter for the (0,0) response pattern in the treatment group.

a_t_01

A positive numeric scalar; see a_t_00.

a_t_10

A positive numeric scalar; see a_t_00.

a_t_11

A positive numeric scalar; see a_t_00.

a_c_00

A positive numeric scalar giving the Dirichlet prior parameter for the (0,0) response pattern in the control group.

a_c_01

A positive numeric scalar; see a_c_00.

a_c_10

A positive numeric scalar; see a_c_00.

a_c_11

A positive numeric scalar; see a_c_00.

theta_TV1

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

theta_MAV1

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

theta_TV2

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

theta_MAV2

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

theta_NULL1

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

theta_NULL2

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

m_t

A positive integer giving the future sample size for the treatment group. Required when prob = 'predictive'; set to NULL otherwise.

m_c

A positive integer giving the future sample size for the control group. Required when prob = 'predictive'; set to NULL otherwise.

z00

A non-negative integer giving the hypothetical control count for pattern (0,0). Required when design = 'uncontrolled'; otherwise set to NULL.

z01

A non-negative integer; see z00.

z10

A non-negative integer; see z00.

z11

A non-negative integer; see z00.

xe_t_00

A non-negative integer giving the external treatment group count for pattern (0,0). Required when design = 'external' and external treatment data are used; otherwise NULL.

xe_t_01

A non-negative integer; see xe_t_00.

xe_t_10

A non-negative integer; see xe_t_00.

xe_t_11

A non-negative integer; see xe_t_00.

xe_c_00

A non-negative integer giving the external control group count for pattern (0,0). Required when design = 'external' and external control data are used; otherwise NULL.

xe_c_01

A non-negative integer; see xe_c_00.

xe_c_10

A non-negative integer; see xe_c_00.

xe_c_11

A non-negative integer; see xe_c_00.

alpha0e_t

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

alpha0e_c

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

nMC

A positive integer giving the number of Dirichlet draws used to evaluate region probabilities for each count combination in Stage 1. Default is 1000L.

gamma_go_grid

A numeric vector of candidate Go threshold values in (0, 1) to search over. Defaults to seq(0.01, 0.99, by = 0.01).

gamma_nogo_grid

A numeric vector of candidate NoGo threshold values in (0, 1) to search over. Defaults to seq(0.01, 0.99, by = 0.01).

Details

The function uses the same two-stage precompute-then-sweep strategy as pbayesdecisionprob2bin.

Stage 1 (precomputation): pbayespostpred2bin is called for every possible multinomial outcome combination (x_t, x_c) enumerated by allmultinom. The resulting region probability vector is summed over GoRegions and NoGoRegions to obtain \hat{g}_{Go,ij} and \hat{g}_{NoGo,ij}. These are independent of the calibration scenario; only the multinomial weights differ.

Stage 2 (gamma sweep): For each pair (\gamma_{\mathrm{go}}, \gamma_{\mathrm{nogo}}) in the two-dimensional grid, operating characteristics are computed separately under each calibration scenario using the respective multinomial weights:

\Pr(\mathrm{Go}) = \sum_{i,j} w_{ij}^{(\mathrm{go})} \mathbf{1}\!\left[\hat{g}_{Go,ij} \ge \gamma_{\mathrm{go}},\; \hat{g}_{NoGo,ij} < \gamma_{\mathrm{nogo}}\right]

\Pr(\mathrm{NoGo}) = \sum_{i,j} w_{ij}^{(\mathrm{nogo})} \mathbf{1}\!\left[\hat{g}_{NoGo,ij} \ge \gamma_{\mathrm{nogo}},\; \hat{g}_{Go,ij} < \gamma_{\mathrm{go}}\right]

Stage 3 (optimal threshold selection): For each candidate \gamma_{\mathrm{go}}, the worst-case \Pr(\mathrm{Go}) over all \gamma_{\mathrm{nogo}} in gamma_nogo_grid is computed; the optimal \gamma_{\mathrm{go}} is the smallest grid value for which this worst-case probability is less than target_go. Analogously, the optimal \gamma_{\mathrm{nogo}} is the smallest grid value for which the worst-case \Pr(\mathrm{NoGo}) is less than target_nogo.

Value

A list of class getgamma2bin with the following elements:

gamma_go

Optimal Go threshold: the smallest value in gamma_go_grid for which the marginal \Pr(\mathrm{Go}) < \code{target\_go} under the Go-calibration scenario. NA if no such value exists.

gamma_nogo

Optimal NoGo threshold: the smallest value in gamma_nogo_grid for which the marginal \Pr(\mathrm{NoGo}) < \code{target\_nogo} under the NoGo-calibration scenario. NA if no such value exists.

PrGo_opt

Marginal \Pr(\mathrm{Go}) at gamma_go under the Go-calibration scenario. NA if gamma_go is NA.

PrNoGo_opt

Marginal \Pr(\mathrm{NoGo}) at gamma_nogo under the NoGo-calibration scenario. NA if gamma_nogo is NA.

target_go

The value of target_go supplied by the user.

target_nogo

The value of target_nogo supplied by the user.

grid_results

A data frame with columns gamma_grid, PrGo_grid (marginal Go probability under the Go-calibration scenario), and PrNoGo_grid (marginal NoGo probability under the NoGo-calibration scenario).

Examples

# Example 1: Controlled design, posterior probability
# gamma_go  : smallest gamma_go   s.t. max_{gamma_nogo} Pr(Go)   < 0.05 under Null
# gamma_nogo: smallest gamma_nogo s.t. max_{gamma_go}   Pr(NoGo) < 0.20 under Alt

getgamma2bin(
  prob = 'posterior', design = 'controlled',
  GoRegions = 1L, NoGoRegions = 9L,
  pi_t1_go = 0.15, pi_t2_go = 0.20, rho_t_go = 0.0,
  pi_c1_go = 0.15, pi_c2_go = 0.20, rho_c_go = 0.0,
  pi_t1_nogo = 0.35, pi_t2_nogo = 0.40, rho_t_nogo = 0.0,
  pi_c1_nogo = 0.15, pi_c2_nogo = 0.20, rho_c_nogo = 0.0,
  target_go = 0.05, target_nogo = 0.20,
  n_t = 7L, n_c = 7L,
  a_t_00 = 0.25, a_t_01 = 0.25, a_t_10 = 0.25, a_t_11 = 0.25,
  a_c_00 = 0.25, a_c_01 = 0.25, a_c_10 = 0.25, a_c_11 = 0.25,
  theta_TV1   = 0.15, theta_MAV1 = 0.10,
  theta_TV2   = 0.15, theta_MAV2 = 0.10,
  theta_NULL1 = NULL, theta_NULL2 = NULL,
  m_t = NULL, m_c = NULL,
  z00 = NULL, z01 = NULL, z10 = NULL, z11 = NULL,
  xe_t_00 = NULL, xe_t_01 = NULL, xe_t_10 = NULL, xe_t_11 = NULL,
  xe_c_00 = NULL, xe_c_01 = NULL, xe_c_10 = NULL, xe_c_11 = NULL,
  alpha0e_t = NULL, alpha0e_c = NULL,
  nMC = 100L,
  gamma_go_grid = seq(0.01, 0.99, by = 0.01),
  gamma_nogo_grid = seq(0.01, 0.99, by = 0.01)
)


# Example 2: Uncontrolled design, posterior probability

getgamma2bin(
  prob = 'posterior', design = 'uncontrolled',
  GoRegions = 1L, NoGoRegions = 9L,
  pi_t1_go = 0.15, pi_t2_go = 0.20, rho_t_go = 0.0,
  pi_c1_go = NULL, pi_c2_go = NULL, rho_c_go = NULL,
  pi_t1_nogo = 0.35, pi_t2_nogo = 0.40, rho_t_nogo = 0.0,
  pi_c1_nogo = NULL, pi_c2_nogo = NULL, rho_c_nogo = NULL,
  target_go = 0.05, target_nogo = 0.20,
  n_t = 7L, n_c = 7L,
  a_t_00 = 0.25, a_t_01 = 0.25, a_t_10 = 0.25, a_t_11 = 0.25,
  a_c_00 = 0.25, a_c_01 = 0.25, a_c_10 = 0.25, a_c_11 = 0.25,
  theta_TV1   = 0.15, theta_MAV1 = 0.10,
  theta_TV2   = 0.15, theta_MAV2 = 0.10,
  theta_NULL1 = NULL, theta_NULL2 = NULL,
  m_t = NULL, m_c = NULL,
  z00 = 3L, z01 = 2L, z10 = 3L, z11 = 2L,
  xe_t_00 = NULL, xe_t_01 = NULL, xe_t_10 = NULL, xe_t_11 = NULL,
  xe_c_00 = NULL, xe_c_01 = NULL, xe_c_10 = NULL, xe_c_11 = NULL,
  alpha0e_t = NULL, alpha0e_c = NULL,
  nMC = 100L,
  gamma_go_grid = seq(0.01, 0.99, by = 0.01),
  gamma_nogo_grid = seq(0.01, 0.99, by = 0.01)
)


# Example 3: External design, posterior probability

getgamma2bin(
  prob = 'posterior', design = 'external',
  GoRegions = 1L, NoGoRegions = 9L,
  pi_t1_go = 0.15, pi_t2_go = 0.20, rho_t_go = 0.0,
  pi_c1_go = 0.15, pi_c2_go = 0.20, rho_c_go = 0.0,
  pi_t1_nogo = 0.35, pi_t2_nogo = 0.40, rho_t_nogo = 0.0,
  pi_c1_nogo = 0.15, pi_c2_nogo = 0.20, rho_c_nogo = 0.0,
  target_go = 0.05, target_nogo = 0.20,
  n_t = 7L, n_c = 7L,
  a_t_00 = 0.25, a_t_01 = 0.25, a_t_10 = 0.25, a_t_11 = 0.25,
  a_c_00 = 0.25, a_c_01 = 0.25, a_c_10 = 0.25, a_c_11 = 0.25,
  theta_TV1   = 0.15, theta_MAV1 = 0.10,
  theta_TV2   = 0.15, theta_MAV2 = 0.10,
  theta_NULL1 = NULL, theta_NULL2 = NULL,
  m_t = NULL, m_c = NULL,
  z00 = NULL, z01 = NULL, z10 = NULL, z11 = NULL,
  xe_t_00 = NULL, xe_t_01 = NULL, xe_t_10 = NULL, xe_t_11 = NULL,
  xe_c_00 = 3L, xe_c_01 = 2L, xe_c_10 = 3L, xe_c_11 = 2L,
  alpha0e_t = NULL, alpha0e_c = 0.5,
  nMC = 100L,
  gamma_go_grid = seq(0.01, 0.99, by = 0.01),
  gamma_nogo_grid = seq(0.01, 0.99, by = 0.01)
)


# Example 4: Controlled design, predictive probability

getgamma2bin(
  prob = 'predictive', design = 'controlled',
  GoRegions = 1L, NoGoRegions = 4L,
  pi_t1_go = 0.15, pi_t2_go = 0.20, rho_t_go = 0.0,
  pi_c1_go = 0.15, pi_c2_go = 0.20, rho_c_go = 0.0,
  pi_t1_nogo = 0.35, pi_t2_nogo = 0.40, rho_t_nogo = 0.0,
  pi_c1_nogo = 0.15, pi_c2_nogo = 0.20, rho_c_nogo = 0.0,
  target_go = 0.05, target_nogo = 0.20,
  n_t = 7L, n_c = 7L,
  a_t_00 = 0.25, a_t_01 = 0.25, a_t_10 = 0.25, a_t_11 = 0.25,
  a_c_00 = 0.25, a_c_01 = 0.25, a_c_10 = 0.25, a_c_11 = 0.25,
  theta_TV1   = NULL, theta_MAV1 = NULL,
  theta_TV2   = NULL, theta_MAV2 = NULL,
  theta_NULL1 = 0.10, theta_NULL2 = 0.10,
  m_t = 5L, m_c = 5L,
  z00 = NULL, z01 = NULL, z10 = NULL, z11 = NULL,
  xe_t_00 = NULL, xe_t_01 = NULL, xe_t_10 = NULL, xe_t_11 = NULL,
  xe_c_00 = NULL, xe_c_01 = NULL, xe_c_10 = NULL, xe_c_11 = NULL,
  alpha0e_t = NULL, alpha0e_c = NULL,
  nMC = 100L,
  gamma_go_grid = seq(0.01, 0.99, by = 0.01),
  gamma_nogo_grid = seq(0.01, 0.99, by = 0.01)
)


# Example 5: Uncontrolled design, predictive probability

getgamma2bin(
  prob = 'predictive', design = 'uncontrolled',
  GoRegions = 1L, NoGoRegions = 4L,
  pi_t1_go = 0.15, pi_t2_go = 0.20, rho_t_go = 0.0,
  pi_c1_go = NULL, pi_c2_go = NULL, rho_c_go = NULL,
  pi_t1_nogo = 0.35, pi_t2_nogo = 0.40, rho_t_nogo = 0.0,
  pi_c1_nogo = NULL, pi_c2_nogo = NULL, rho_c_nogo = NULL,
  target_go = 0.05, target_nogo = 0.20,
  n_t = 7L, n_c = 7L,
  a_t_00 = 0.25, a_t_01 = 0.25, a_t_10 = 0.25, a_t_11 = 0.25,
  a_c_00 = 0.25, a_c_01 = 0.25, a_c_10 = 0.25, a_c_11 = 0.25,
  theta_TV1   = NULL, theta_MAV1 = NULL,
  theta_TV2   = NULL, theta_MAV2 = NULL,
  theta_NULL1 = 0.10, theta_NULL2 = 0.10,
  m_t = 5L, m_c = 5L,
  z00 = 3L, z01 = 2L, z10 = 3L, z11 = 2L,
  xe_t_00 = NULL, xe_t_01 = NULL, xe_t_10 = NULL, xe_t_11 = NULL,
  xe_c_00 = NULL, xe_c_01 = NULL, xe_c_10 = NULL, xe_c_11 = NULL,
  alpha0e_t = NULL, alpha0e_c = NULL,
  nMC = 100L,
  gamma_go_grid = seq(0.01, 0.99, by = 0.01),
  gamma_nogo_grid = seq(0.01, 0.99, by = 0.01)
)


# Example 6: External design, predictive probability

getgamma2bin(
  prob = 'predictive', design = 'external',
  GoRegions = 1L, NoGoRegions = 4L,
  pi_t1_go = 0.15, pi_t2_go = 0.20, rho_t_go = 0.0,
  pi_c1_go = 0.15, pi_c2_go = 0.20, rho_c_go = 0.0,
  pi_t1_nogo = 0.35, pi_t2_nogo = 0.40, rho_t_nogo = 0.0,
  pi_c1_nogo = 0.15, pi_c2_nogo = 0.20, rho_c_nogo = 0.0,
  target_go = 0.05, target_nogo = 0.20,
  n_t = 7L, n_c = 7L,
  a_t_00 = 0.25, a_t_01 = 0.25, a_t_10 = 0.25, a_t_11 = 0.25,
  a_c_00 = 0.25, a_c_01 = 0.25, a_c_10 = 0.25, a_c_11 = 0.25,
  theta_TV1   = NULL, theta_MAV1 = NULL,
  theta_TV2   = NULL, theta_MAV2 = NULL,
  theta_NULL1 = 0.10, theta_NULL2 = 0.10,
  m_t = 5L, m_c = 5L,
  z00 = NULL, z01 = NULL, z10 = NULL, z11 = NULL,
  xe_t_00 = 3L, xe_t_01 = 2L, xe_t_10 = 3L, xe_t_11 = 2L,
  xe_c_00 = NULL, xe_c_01 = NULL, xe_c_10 = NULL, xe_c_11 = NULL,
  alpha0e_t = 0.5, alpha0e_c = NULL,
  nMC = 100L,
  gamma_go_grid = seq(0.01, 0.99, by = 0.01),
  gamma_nogo_grid = seq(0.01, 0.99, by = 0.01)
)



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