getgamma1bin: Find Optimal Go/NoGo Thresholds for a Single Binary Endpoint

View source: R/getgamma1bin.R

getgamma1binR Documentation

Find Optimal Go/NoGo Thresholds for a Single Binary Endpoint

Description

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

  • \gamma_{\mathrm{go}} is the smallest value in gamma_grid such that the marginal Go probability \Pr(g_{\mathrm{Go}} \ge \gamma_{\mathrm{go}}) is strictly less than target_go under the Go-calibration scenario (pi_t_go, pi_c_go); typically the Null scenario.

  • \gamma_{\mathrm{nogo}} is the smallest value in gamma_grid such that the marginal NoGo probability \Pr(g_{\mathrm{NoGo}} \ge \gamma_{\mathrm{nogo}}) is strictly less than target_nogo under the NoGo-calibration scenario (pi_t_nogo, pi_c_nogo); typically the Alternative scenario.

Here g_{\mathrm{Go}} = P(\theta > \theta_{\mathrm{TV}} \mid y_t, y_c) and g_{\mathrm{NoGo}} = P(\theta \le \theta_{\mathrm{MAV}} \mid y_t, y_c) for prob = 'posterior', consistent with the decision rule in pbayesdecisionprob1bin.

Usage

getgamma1bin(
  prob = "posterior",
  design = "controlled",
  theta_TV = NULL,
  theta_MAV = NULL,
  theta_NULL = NULL,
  pi_t_go,
  pi_c_go = NULL,
  pi_t_nogo,
  pi_c_nogo = NULL,
  target_go,
  target_nogo,
  n_t,
  n_c,
  a_t,
  a_c,
  b_t,
  b_c,
  z = NULL,
  m_t = NULL,
  m_c = NULL,
  ne_t = NULL,
  ne_c = NULL,
  ye_t = NULL,
  ye_c = NULL,
  alpha0e_t = NULL,
  alpha0e_c = NULL,
  gamma_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'.

theta_TV

A numeric scalar in (-1, 1) giving the Target Value (TV) threshold for the treatment effect. Required when prob = 'posterior'; set to NULL otherwise.

theta_MAV

A numeric scalar in (-1, 1) giving the Minimum Acceptable Value (MAV) threshold. Must satisfy theta_TV > theta_MAV. Required when prob = 'posterior'; set to NULL otherwise.

theta_NULL

A numeric scalar in (-1, 1) giving the null hypothesis threshold used for the predictive probability. Required when prob = 'predictive'; set to NULL otherwise.

pi_t_go

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

pi_c_go

A numeric scalar in (0, 1) giving the true control response rate under the Go-calibration scenario. Set to NULL for design = 'uncontrolled'.

pi_t_nogo

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

pi_c_nogo

A numeric scalar in (0, 1) giving the true control response rate under the NoGo-calibration scenario. Set to NULL for design = 'uncontrolled'.

target_go

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

target_nogo

A numeric scalar in (0, 1) giving the upper bound on the marginal NoGo probability under the NoGo-calibration scenario. The optimal \gamma_{\mathrm{nogo}} is the largest grid value satisfying \Pr(\mathrm{NoGo}) < \code{target\_nogo}.

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

A positive numeric scalar giving the first shape parameter of the Beta prior for the treatment group.

a_c

A positive numeric scalar giving the first shape parameter of the Beta prior for the control group.

b_t

A positive numeric scalar giving the second shape parameter of the Beta prior for the treatment group.

b_c

A positive numeric scalar giving the second shape parameter of the Beta prior for the control group.

z

A non-negative integer giving the hypothetical number of responders in the control group. Required when design = 'uncontrolled'; set to NULL otherwise.

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.

ne_t

A positive integer giving the number of patients in the treatment group of the external data set. Required when design = 'external'; set to NULL otherwise.

ne_c

A positive integer giving the number of patients in the control group of the external data set. Required when design = 'external'; set to NULL otherwise.

ye_t

A non-negative integer giving the number of responders in the treatment group of the external data set. Required when design = 'external'; set to NULL otherwise.

ye_c

A non-negative integer giving the number of responders in the control group of the external data set. Required when design = 'external'; set to NULL otherwise.

alpha0e_t

A numeric scalar in (0, 1] giving the power prior weight for the treatment group. Required when design = 'external'; set to NULL otherwise.

alpha0e_c

A numeric scalar in (0, 1] giving the power prior weight for the control group. Required when design = 'external'; set to NULL otherwise.

gamma_grid

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

Details

The function uses a two-stage precompute-then-sweep strategy:

  1. Precomputation: All possible outcome pairs (y_t, y_c) are enumerated. For each pair, pbayespostpred1bin computes g_{\mathrm{Go}} (lower.tail = FALSE at theta_TV) and g_{\mathrm{NoGo}} (lower.tail = TRUE at theta_MAV). This step is independent of \gamma.

  2. Gamma sweep: Marginal probabilities are computed as weighted sums of binary indicators over the grid: \Pr(\mathrm{Go}) uses w_go (weights under pi_t_go, pi_c_go) and the indicator g_{\mathrm{Go}} \ge \gamma; \Pr(\mathrm{NoGo}) uses w_nogo (weights under pi_t_nogo, pi_c_nogo) and the indicator g_{\mathrm{NoGo}} \ge \gamma.

Both \Pr(\mathrm{Go}) and \Pr(\mathrm{NoGo}) are monotone non-increasing functions of \gamma. The optimal \gamma_{\mathrm{go}} is the smallest grid value crossing below target_go. The optimal \gamma_{\mathrm{nogo}} is also the smallest grid value crossing below target_nogo: a smaller \gamma_{\mathrm{nogo}} makes NoGo harder to trigger (more permissive), so this is the least restrictive threshold that still controls the false NoGo rate.

Value

A list of class getgamma1bin with the following elements:

gamma_go

Optimal Go threshold: the smallest value in gamma_grid for which \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_grid for which \Pr(\mathrm{NoGo}) < \code{target\_nogo} under the NoGo-calibration scenario. NA if no such value exists.

PrGo_opt

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

PrNoGo_opt

Marginal \Pr(g_{\mathrm{NoGo}} \ge \gamma_{\mathrm{nogo}}) at the optimal \gamma_{\mathrm{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 s.t. Pr(Go)   < 0.05 under Null (pi_t = pi_c = 0.15)
# gamma_nogo: largest  gamma s.t. Pr(NoGo) < 0.20 under Alt  (pi_t = 0.35, pi_c = 0.15)
getgamma1bin(
  prob = 'posterior', design = 'controlled',
  theta_TV = 0.20, theta_MAV = 0.05, theta_NULL = NULL,
  pi_t_go = 0.15, pi_c_go = 0.15,
  pi_t_nogo = 0.35, pi_c_nogo = 0.15,
  target_go = 0.05, target_nogo = 0.20,
  n_t = 12L, n_c = 12L,
  a_t = 0.5, a_c = 0.5, b_t = 0.5, b_c = 0.5,
  z = NULL, m_t = NULL, m_c = NULL,
  ne_t = NULL, ne_c = NULL, ye_t = NULL, ye_c = NULL,
  alpha0e_t = NULL, alpha0e_c = NULL
)

# Example 2: Uncontrolled design, posterior probability
getgamma1bin(
  prob = 'posterior', design = 'uncontrolled',
  theta_TV = 0.20, theta_MAV = 0.05, theta_NULL = NULL,
  pi_t_go = 0.15, pi_c_go = NULL,
  pi_t_nogo = 0.35, pi_c_nogo = NULL,
  target_go = 0.05, target_nogo = 0.20,
  n_t = 12L, n_c = 12L,
  a_t = 0.5, a_c = 0.5, b_t = 0.5, b_c = 0.5,
  z = 3L, m_t = NULL, m_c = NULL,
  ne_t = NULL, ne_c = NULL, ye_t = NULL, ye_c = NULL,
  alpha0e_t = NULL, alpha0e_c = NULL
)

# Example 3: External design, posterior probability
getgamma1bin(
  prob = 'posterior', design = 'external',
  theta_TV = 0.20, theta_MAV = 0.05, theta_NULL = NULL,
  pi_t_go = 0.15, pi_c_go = 0.15,
  pi_t_nogo = 0.35, pi_c_nogo = 0.15,
  target_go = 0.05, target_nogo = 0.20,
  n_t = 12L, n_c = 12L,
  a_t = 0.5, a_c = 0.5, b_t = 0.5, b_c = 0.5,
  z = NULL, m_t = NULL, m_c = NULL,
  ne_t = 15L, ne_c = 15L, ye_t = 6L, ye_c = 4L,
  alpha0e_t = 0.5, alpha0e_c = 0.5
)

# Example 4: Controlled design, predictive probability
getgamma1bin(
  prob = 'predictive', design = 'controlled',
  theta_TV = NULL, theta_MAV = NULL, theta_NULL = 0.10,
  pi_t_go = 0.15, pi_c_go = 0.15,
  pi_t_nogo = 0.35, pi_c_nogo = 0.15,
  target_go = 0.05, target_nogo = 0.20,
  n_t = 12L, n_c = 12L,
  a_t = 0.5, a_c = 0.5, b_t = 0.5, b_c = 0.5,
  z = NULL, m_t = 30L, m_c = 30L,
  ne_t = NULL, ne_c = NULL, ye_t = NULL, ye_c = NULL,
  alpha0e_t = NULL, alpha0e_c = NULL
)

# Example 5: Uncontrolled design, predictive probability
getgamma1bin(
  prob = 'predictive', design = 'uncontrolled',
  theta_TV = NULL, theta_MAV = NULL, theta_NULL = 0.10,
  pi_t_go = 0.15, pi_c_go = NULL,
  pi_t_nogo = 0.35, pi_c_nogo = NULL,
  target_go = 0.05, target_nogo = 0.20,
  n_t = 12L, n_c = 12L,
  a_t = 0.5, a_c = 0.5, b_t = 0.5, b_c = 0.5,
  z = 3L, m_t = 30L, m_c = 30L,
  ne_t = NULL, ne_c = NULL, ye_t = NULL, ye_c = NULL,
  alpha0e_t = NULL, alpha0e_c = NULL
)

# Example 6: External design, predictive probability
getgamma1bin(
  prob = 'predictive', design = 'external',
  theta_TV = NULL, theta_MAV = NULL, theta_NULL = 0.10,
  pi_t_go = 0.15, pi_c_go = 0.15,
  pi_t_nogo = 0.35, pi_c_nogo = 0.15,
  target_go = 0.05, target_nogo = 0.20,
  n_t = 12L, n_c = 12L,
  a_t = 0.5, a_c = 0.5, b_t = 0.5, b_c = 0.5,
  z = NULL, m_t = 30L, m_c = 30L,
  ne_t = 15L, ne_c = 15L, ye_t = 6L, ye_c = 4L,
  alpha0e_t = 0.5, alpha0e_c = 0.5
)


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