View source: R/getgamma2cont.R
| getgamma2cont | R Documentation |
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.
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
)
nsim |
A positive integer giving the number of Monte Carlo
datasets to simulate per calibration scenario. Default is
|
prob |
A character string specifying the probability type.
Must be |
design |
A character string specifying the trial design.
Must be |
prior |
A character string specifying the prior distribution.
Must be |
GoRegions |
An integer vector of region indices (subset of
|
NoGoRegions |
An integer vector of region indices (subset of
|
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 |
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
|
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 |
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
|
target_go |
A numeric scalar in |
target_nogo |
A numeric scalar in |
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 |
theta_TV1 |
A numeric scalar giving the TV threshold for
Endpoint 1. Required when |
theta_MAV1 |
A numeric scalar giving the MAV threshold for
Endpoint 1. Required when |
theta_TV2 |
A numeric scalar giving the TV threshold for
Endpoint 2. Required when |
theta_MAV2 |
A numeric scalar giving the MAV threshold for
Endpoint 2. Required when |
theta_NULL1 |
A numeric scalar giving the null hypothesis threshold
for Endpoint 1. Required when |
theta_NULL2 |
A numeric scalar giving the null hypothesis threshold
for Endpoint 2. Required when |
m_t |
A positive integer giving the future sample size for the
treatment group. Required when |
m_c |
A positive integer giving the future sample size for the
control group. Required when |
kappa0_t |
Positive numeric scalar. NIW prior hyperparameter
|
nu0_t |
Positive numeric scalar. NIW prior degrees of freedom
|
mu0_t |
Length-2 numeric vector. NIW prior mean |
Lambda0_t |
A 2x2 positive-definite numeric matrix. NIW prior
scale matrix |
kappa0_c |
Positive numeric scalar; see |
nu0_c |
Positive numeric scalar; see |
mu0_c |
Length-2 numeric vector; see |
Lambda0_c |
A 2x2 matrix; see |
r |
A positive numeric scalar giving the power prior weight for
the control group when |
ne_t |
A positive integer giving the external treatment sample size.
Required when |
ne_c |
A positive integer giving the external control sample size.
Required when |
alpha0e_t |
A numeric scalar in |
alpha0e_c |
A numeric scalar in |
bar_ye_t |
A length-2 numeric vector. External treatment sample
mean. Required when external treatment data are used;
otherwise |
bar_ye_c |
A length-2 numeric vector. External control sample mean.
Required when external control data are used; otherwise |
se_t |
A 2x2 numeric matrix. External treatment sum-of-squares
matrix. Required when external treatment data are used;
otherwise |
se_c |
A 2x2 numeric matrix. External control sum-of-squares
matrix. Required when external control data are used;
otherwise |
nMC |
A positive integer giving the number of Monte Carlo draws
passed to |
CalcMethod |
A character string specifying the computation method
passed to |
gamma_go_grid |
A numeric vector of candidate Go threshold values
in |
gamma_nogo_grid |
A numeric vector of candidate NoGo threshold
values in |
seed |
A numeric scalar for reproducible random number generation.
The Go-calibration simulation uses |
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.
A list of class getgamma2cont with the following elements:
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.
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.
Marginal \Pr(\mathrm{Go}) at
gamma_go under the Go-calibration scenario.
NA if gamma_go is NA.
Marginal \Pr(\mathrm{NoGo}) at
gamma_nogo under the NoGo-calibration scenario.
NA if gamma_nogo is NA.
The value of target_go supplied by the user.
The value of target_nogo supplied by the user.
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).
# 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
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.