getgamma2cont: Find Optimal Go/NoGo Thresholds for Two Continuous Endpoints

View source: R/getgamma2cont.R

getgamma2contR Documentation

Find Optimal Go/NoGo Thresholds for Two Continuous Endpoints

Description

Computes the optimal Go threshold \gamma_{\mathrm{go}} and NoGo threshold \gamma_{\mathrm{nogo}} for two continuous endpoints by searching independently over candidate threshold grids. The two thresholds are calibrated marginally under separate scenarios:

  • \gamma_{\mathrm{go}} is the smallest value in gamma_go_grid such that the marginal Go probability is strictly less than target_go under the Go-calibration scenario (mu_t_go, Sigma_t_go, mu_c_go, Sigma_c_go); typically the Null scenario.

  • \gamma_{\mathrm{nogo}} is the smallest value in gamma_nogo_grid such that the marginal NoGo probability is strictly less than target_nogo under the NoGo-calibration scenario (mu_t_nogo, Sigma_t_nogo, mu_c_nogo, Sigma_c_nogo); typically the Alternative scenario.

Usage

getgamma2cont(
  nsim = 10000L,
  prob = "posterior",
  design = "controlled",
  prior = "vague",
  GoRegions,
  NoGoRegions,
  mu_t_go,
  Sigma_t_go,
  mu_c_go = NULL,
  Sigma_c_go = NULL,
  mu_t_nogo,
  Sigma_t_nogo,
  mu_c_nogo = NULL,
  Sigma_c_nogo = NULL,
  target_go,
  target_nogo,
  n_t,
  n_c = NULL,
  theta_TV1 = NULL,
  theta_MAV1 = NULL,
  theta_TV2 = NULL,
  theta_MAV2 = NULL,
  theta_NULL1 = NULL,
  theta_NULL2 = NULL,
  m_t = NULL,
  m_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",
  gamma_go_grid = seq(0.01, 0.99, by = 0.01),
  gamma_nogo_grid = seq(0.01, 0.99, by = 0.01),
  seed
)

Arguments

nsim

A positive integer giving the number of Monte Carlo datasets to simulate per calibration scenario. Default is 10000L.

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 of region indices (subset of 1:9) that constitute the Go region. The 9 regions are defined by the cross-classification of the two treatment effects (\theta_1, \theta_2) relative to (TV1, MAV1) and (TV2, MAV2): region k = (z_1 - 1) \times 3 + z_2 where z_i = 1 if \theta_i > TV_i, z_i = 2 if MAV_i < \theta_i \le TV_i, z_i = 3 if \theta_i \le MAV_i.

NoGoRegions

An integer vector of region indices (subset of 1:9) that constitute the NoGo region. Must be disjoint from GoRegions.

mu_t_go

A length-2 numeric vector giving the true bivariate mean for the treatment group under the Go-calibration scenario (typically Null).

Sigma_t_go

A 2x2 positive-definite numeric matrix giving the true within-group covariance in the treatment group under the Go-calibration scenario.

mu_c_go

A length-2 numeric vector giving the true bivariate mean for the control group under the Go-calibration scenario. Required for design = 'controlled' or 'external'; set to NULL for design = 'uncontrolled'.

Sigma_c_go

A 2x2 positive-definite numeric matrix giving the true within-group covariance in the control group under the Go-calibration scenario. Required for design = 'controlled' or 'external'; set to NULL for design = 'uncontrolled'.

mu_t_nogo

A length-2 numeric vector giving the true bivariate mean for the treatment group under the NoGo-calibration scenario (typically Alternative).

Sigma_t_nogo

A 2x2 positive-definite numeric matrix giving the true within-group covariance in the treatment group under the NoGo-calibration scenario.

mu_c_nogo

A length-2 numeric vector giving the true bivariate mean for the control group under the NoGo-calibration scenario. Required for design = 'controlled' or 'external'; set to NULL for design = 'uncontrolled'.

Sigma_c_nogo

A 2x2 positive-definite numeric matrix giving the true within-group covariance 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 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 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. Set to NULL for design = 'uncontrolled'.

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.

kappa0_t

Positive numeric scalar. NIW prior hyperparameter \kappa_{01} for the treatment group. Required when prior = 'N-Inv-Wishart'; otherwise NULL.

nu0_t

Positive numeric scalar. NIW prior degrees of freedom \nu_{01} for the treatment group. Required when prior = 'N-Inv-Wishart'; otherwise NULL.

mu0_t

Length-2 numeric vector. NIW prior mean \mu_{01} for the treatment group. Required when prior = 'N-Inv-Wishart'; otherwise NULL.

Lambda0_t

A 2x2 positive-definite numeric matrix. NIW prior scale matrix \Lambda_{01} for the treatment group. Required when prior = 'N-Inv-Wishart'; otherwise NULL.

kappa0_c

Positive numeric scalar; see kappa0_t. For the control group.

nu0_c

Positive numeric scalar; see nu0_t. For the control group.

mu0_c

Length-2 numeric vector; see mu0_t. For the control group. May be required for the vague prior uncontrolled design; see pbayesdecisionprob2cont.

Lambda0_c

A 2x2 matrix; see Lambda0_t. For the control group.

r

A positive numeric scalar giving the power prior weight for the control group when design = 'uncontrolled' and prior = 'vague'. Otherwise NULL.

ne_t

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

ne_c

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

alpha0e_t

A numeric scalar in (0, 1] giving the power prior weight for external treatment 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 data. Required when external control data are used; otherwise NULL.

bar_ye_t

A length-2 numeric vector. External treatment sample mean. Required when external treatment data are used; otherwise NULL.

bar_ye_c

A length-2 numeric vector. External control sample mean. Required when external control data are used; otherwise NULL.

se_t

A 2x2 numeric matrix. External treatment sum-of-squares matrix. Required when external treatment data are used; otherwise NULL.

se_c

A 2x2 numeric matrix. External control sum-of-squares matrix. Required when external control data are used; otherwise NULL.

nMC

A positive integer giving the number of Monte Carlo draws passed to pbayespostpred2cont. Required when CalcMethod = 'MC'. May be set to NULL when CalcMethod = 'MM' and \nu_k > 4; if CalcMethod = 'MM' but \nu_k \le 4 causes a fallback to MC, nMC must be a positive integer. Default is NULL.

CalcMethod

A character string specifying the computation method passed to pbayespostpred2cont. Must be 'MC' (default) or 'MM'.

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

seed

A numeric scalar for reproducible random number generation. The Go-calibration simulation uses seed and the NoGo-calibration simulation uses seed + 1 to ensure independence between the two scenarios.

Details

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

Stage 1 (simulation and precomputation): nsim bivariate datasets are generated independently for each calibration scenario. For the Go-calibration scenario, datasets are drawn from N_2(\mu_{t,\mathrm{go}}, \Sigma_{t,\mathrm{go}}) (and N_2(\mu_{c,\mathrm{go}}, \Sigma_{c,\mathrm{go}}) for controlled/external designs); for the NoGo-calibration scenario, the corresponding _nogo parameters are used. pbayespostpred2cont is called once per scenario in vectorised mode to return an nsim \times 9 matrix of region probabilities. The probabilities are summed over GoRegions (for the Go scenario) and NoGoRegions (for the NoGo scenario) to obtain \hat{g}_{Go,i} and \hat{g}_{NoGo,i}, independent of the decision thresholds.

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:

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

\Pr(\mathrm{NoGo}) = \frac{1}{n_{\mathrm{sim}}} \sum_{i=1}^{n_{\mathrm{sim}}} \mathbf{1}\!\left[\hat{g}_{NoGo,i} \ge \gamma_{\mathrm{nogo}},\; \hat{g}_{Go,i} < \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 getgamma2cont 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, vague prior
# 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

Sigma_null <- matrix(c(6400.0, 15.0, 15.0, 36.0), 2, 2)
Sigma_alt  <- matrix(c(6400.0, 15.0, 15.0, 36.0), 2, 2)
getgamma2cont(
  nsim = 1000L, prob = 'posterior', design = 'controlled',
  prior = 'vague',
  GoRegions = 1L, NoGoRegions = 9L,
  mu_t_go = c(-5.0, 0.0), Sigma_t_go = Sigma_null,
  mu_c_go = c(-10.0, -1.0), Sigma_c_go = Sigma_null,
  mu_t_nogo = c(5.0, 1.0), Sigma_t_nogo = Sigma_alt,
  mu_c_nogo = c(-10.0, -1.0), Sigma_c_nogo = Sigma_alt,
  target_go = 0.05, target_nogo = 0.20,
  n_t = 30L, n_c = 30L,
  theta_TV1 = 10.0, theta_MAV1 = 5.0,
  theta_TV2 = 2.0,  theta_MAV2 = 1.0,
  theta_NULL1 = NULL, theta_NULL2 = NULL,
  m_t = NULL, m_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 = 500L, CalcMethod = 'MC',
  gamma_go_grid = seq(0.01, 0.99, by = 0.01),
  gamma_nogo_grid = seq(0.01, 0.99, by = 0.01),
  seed = 1L
)


# Example 2: Uncontrolled design, posterior probability, vague prior

Sigma_null <- matrix(c(6400.0, 15.0, 15.0, 36.0), 2, 2)
Sigma_alt  <- matrix(c(6400.0, 15.0, 15.0, 36.0), 2, 2)
getgamma2cont(
  nsim = 1000L, prob = 'posterior', design = 'uncontrolled',
  prior = 'vague',
  GoRegions = 1L, NoGoRegions = 9L,
  mu_t_go = c(-5.0, 0.0), Sigma_t_go = Sigma_null,
  mu_c_go = NULL, Sigma_c_go = NULL,
  mu_t_nogo = c(5.0, 1.0), Sigma_t_nogo = Sigma_alt,
  mu_c_nogo = NULL, Sigma_c_nogo = NULL,
  target_go = 0.05, target_nogo = 0.20,
  n_t = 30L, n_c = NULL,
  theta_TV1 = 10.0, theta_MAV1 = 5.0,
  theta_TV2 = 2.0,  theta_MAV2 = 1.0,
  theta_NULL1 = NULL, theta_NULL2 = NULL,
  m_t = NULL, m_c = NULL,
  kappa0_t = NULL, nu0_t = NULL, mu0_t = NULL, Lambda0_t = NULL,
  kappa0_c = NULL, nu0_c = NULL, mu0_c = c(-10.0, -1.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 = NULL, CalcMethod = 'MM',
  gamma_go_grid = seq(0.01, 0.99, by = 0.01),
  gamma_nogo_grid = seq(0.01, 0.99, by = 0.01),
  seed = 1L
)


# Example 3: External design (control only), posterior probability, NIW prior

Sigma  <- matrix(c(6400.0, 15.0, 15.0, 36.0), 2, 2)
Lambda <- matrix(c(6400.0, 15.0, 15.0, 36.0), 2, 2)
se_c   <- matrix(c(6400.0, 15.0, 15.0, 36.0), 2, 2)
getgamma2cont(
  nsim = 1000L, prob = 'posterior', design = 'external',
  prior = 'N-Inv-Wishart',
  GoRegions = 1L, NoGoRegions = 9L,
  mu_t_go = c(-5.0, 0.0), Sigma_t_go = Sigma,
  mu_c_go = c(-10.0, -1.0), Sigma_c_go = Sigma,
  mu_t_nogo = c(5.0, 1.0), Sigma_t_nogo = Sigma,
  mu_c_nogo = c(-10.0, -1.0), Sigma_c_nogo = Sigma,
  target_go = 0.05, target_nogo = 0.20,
  n_t = 30L, n_c = 30L,
  theta_TV1 = 10.0, theta_MAV1 = 5.0,
  theta_TV2 = 2.0,  theta_MAV2 = 1.0,
  theta_NULL1 = NULL, theta_NULL2 = NULL,
  m_t = NULL, m_c = NULL,
  kappa0_t = 0.1, nu0_t = 4.0, mu0_t = c(0.0, 1.0),  Lambda0_t = Lambda,
  kappa0_c = 0.1, nu0_c = 4.0, mu0_c = c(-10.0, -1.0), Lambda0_c = Lambda,
  r = NULL,
  ne_t = NULL, ne_c = 10L, alpha0e_t = NULL, alpha0e_c = 0.5,
  bar_ye_t = NULL, bar_ye_c = c(-10.0, -1.0), se_t = NULL, se_c = se_c,
  nMC = 500L, CalcMethod = 'MC',
  gamma_go_grid = seq(0.01, 0.99, by = 0.01),
  gamma_nogo_grid = seq(0.01, 0.99, by = 0.01),
  seed = 1L
)


# Example 4: Controlled design, predictive probability, vague prior

Sigma_null <- matrix(c(6400.0, 15.0, 15.0, 36.0), 2, 2)
Sigma_alt  <- matrix(c(6400.0, 15.0, 15.0, 36.0), 2, 2)
getgamma2cont(
  nsim = 1000L, prob = 'predictive', design = 'controlled',
  prior = 'vague',
  GoRegions = 1L, NoGoRegions = 4L,
  mu_t_go = c(-5.0, 0.0), Sigma_t_go = Sigma_null,
  mu_c_go = c(-10.0, -1.0), Sigma_c_go = Sigma_null,
  mu_t_nogo = c(5.0, 1.0), Sigma_t_nogo = Sigma_alt,
  mu_c_nogo = c(-10.0, -1.0), Sigma_c_nogo = Sigma_alt,
  target_go = 0.05, target_nogo = 0.20,
  n_t = 30L, n_c = 30L,
  theta_TV1 = NULL, theta_MAV1 = NULL,
  theta_TV2 = NULL, theta_MAV2 = NULL,
  theta_NULL1 = 5.0, theta_NULL2 = 1.0,
  m_t = 100L, m_c = 100L,
  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',
  gamma_go_grid = seq(0.01, 0.99, by = 0.01),
  gamma_nogo_grid = seq(0.01, 0.99, by = 0.01),
  seed = 1L
)


# Example 5: Uncontrolled design, predictive probability, vague prior

Sigma_null <- matrix(c(6400.0, 15.0, 15.0, 36.0), 2, 2)
Sigma_alt  <- matrix(c(6400.0, 15.0, 15.0, 36.0), 2, 2)
getgamma2cont(
  nsim = 1000L, prob = 'predictive', design = 'uncontrolled',
  prior = 'vague',
  GoRegions = 1L, NoGoRegions = 4L,
  mu_t_go = c(-5.0, 0.0), Sigma_t_go = Sigma_null,
  mu_c_go = NULL, Sigma_c_go = NULL,
  mu_t_nogo = c(5.0, 1.0), Sigma_t_nogo = Sigma_alt,
  mu_c_nogo = NULL, Sigma_c_nogo = NULL,
  target_go = 0.05, target_nogo = 0.20,
  n_t = 30L, n_c = NULL,
  theta_TV1 = NULL, theta_MAV1 = NULL,
  theta_TV2 = NULL, theta_MAV2 = NULL,
  theta_NULL1 = 5.0, theta_NULL2 = 1.0,
  m_t = 100L, m_c = 100L,
  kappa0_t = NULL, nu0_t = NULL, mu0_t = NULL, Lambda0_t = NULL,
  kappa0_c = NULL, nu0_c = NULL, mu0_c = c(-10.0, -1.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',
  gamma_go_grid = seq(0.01, 0.99, by = 0.01),
  gamma_nogo_grid = seq(0.01, 0.99, by = 0.01),
  seed = 1L
)


# Example 6: External design (control only), predictive probability, NIW prior

Sigma  <- matrix(c(6400.0, 15.0, 15.0, 36.0), 2, 2)
Lambda <- matrix(c(6400.0, 15.0, 15.0, 36.0), 2, 2)
se_c   <- matrix(c(6400.0, 15.0, 15.0, 36.0), 2, 2)
getgamma2cont(
  nsim = 1000L, prob = 'predictive', design = 'external',
  prior = 'N-Inv-Wishart',
  GoRegions = 1L, NoGoRegions = 4L,
  mu_t_go = c(-5.0, 0.0), Sigma_t_go = Sigma,
  mu_c_go = c(-10.0, -1.0), Sigma_c_go = Sigma,
  mu_t_nogo = c(5.0, 1.0), Sigma_t_nogo = Sigma,
  mu_c_nogo = c(-10.0, -1.0), Sigma_c_nogo = Sigma,
  target_go = 0.05, target_nogo = 0.20,
  n_t = 30L, n_c = 30L,
  theta_TV1 = NULL, theta_MAV1 = NULL,
  theta_TV2 = NULL, theta_MAV2 = NULL,
  theta_NULL1 = 5.0, theta_NULL2 = 1.0,
  m_t = 100L, m_c = 100L,
  kappa0_t = 0.1, nu0_t = 4.0, mu0_t = c(0.0, 1.0),  Lambda0_t = Lambda,
  kappa0_c = 0.1, nu0_c = 4.0, mu0_c = c(-10.0, -1.0), Lambda0_c = Lambda,
  r = NULL,
  ne_t = NULL, ne_c = 10L, alpha0e_t = NULL, alpha0e_c = 0.5,
  bar_ye_t = NULL, bar_ye_c = c(-10.0, -1.0), se_t = NULL, se_c = se_c,
  nMC = 500L, CalcMethod = 'MC',
  gamma_go_grid = seq(0.01, 0.99, by = 0.01),
  gamma_nogo_grid = seq(0.01, 0.99, by = 0.01),
  seed = 1L
)



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