| Title: | Bayesian Quantitative Decision-Making Framework for Binary and Continuous Endpoints |
|---|---|
| Description: | Provides comprehensive methods to calculate posterior probabilities, posterior predictive probabilities, and Go/NoGo/Gray decision probabilities for quantitative decision-making under a Bayesian paradigm in clinical trials. The package supports both single and two-endpoint analyses for binary and continuous outcomes, with controlled, uncontrolled, and external designs. For single continuous endpoints, three calculation methods are available: numerical integration (NI), Monte Carlo simulation (MC), and Moment-Matching approximation (MM). For two continuous endpoints, a bivariate Normal-Inverse-Wishart conjugate model is implemented with MC and MM methods. For two binary endpoints, a Dirichlet-multinomial model is implemented. External designs incorporate historical data through power priors using exact conjugate representations (Normal-Inverse-Chi-squared for single continuous, Normal-Inverse-Wishart for two continuous, and Dirichlet for binary endpoints), enabling closed-form posterior computation without Markov chain Monte Carlo (MCMC) sampling. This approach significantly reduces computational burden while preserving complete Bayesian rigor. The package also provides grid-search functions to find optimal Go and NoGo thresholds that satisfy user-specified operating characteristic criteria for all supported endpoint types and study designs. S3 print() and plot() methods are provided for all decision probability classes, enabling formatted display and visualisation of Go/NoGo/Gray operating characteristics across treatment scenarios. See Kang, Yamaguchi, and Han (2026) <doi:10.1080/10543406.2026.2655410> for the methodological framework. |
| Authors: | Gosuke Homma [aut, cre], Yusuke Yamaguchi [aut] |
| Maintainer: | Gosuke Homma <[email protected]> |
| License: | GPL (>= 2) |
| Version: | 0.1.0 |
| Built: | 2026-05-22 07:49:43 UTC |
| Source: | https://github.com/gosukehommaex/bayesianqdm |
Generates the complete set of non-negative integer vectors
satisfying
, where is the
sample size of group . Each row of the returned matrix
corresponds to one possible realisation of the aggregated bivariate binary
counts. This enumeration is a prerequisite for exact operating
characteristic assessment in pbayesdecisionprob2bin.
allmultinom(n)allmultinom(n)
n |
A single non-negative integer giving the sample size of the group
( |
The number of non-negative integer solutions to
is the stars-and-bars count
For example, yields 286 rows and yields
1771 rows. The matrix is pre-allocated to avoid repeated memory
reallocation, making the function efficient for the sample sizes typical
in rare-disease proof-of-concept studies.
This function is an internal computational building block used by
pbayesdecisionprob2bin to enumerate the sample space over
which multinomial probabilities and decision indicators are summed when
computing exact operating characteristics.
An integer matrix with rows and 4 columns
named x00, x01, x10, x11.
Each row is a distinct non-negative integer solution to
.
Rows are ordered by x00 (ascending), then x10
(ascending), then x01 (ascending).
# Example 1: n = 2 (smallest non-trivial case) allmultinom(2) # Example 2: n = 10 (typical rare-disease PoC group size) mat <- allmultinom(10) nrow(mat) # Should be choose(13, 3) = 286 all(rowSums(mat) == 10) # Every row must sum to n # Example 3: n = 0 (edge case - only the all-zero row) allmultinom(0) # Example 4: Verify column names colnames(allmultinom(5)) # Example 5: Row counts match the stars-and-bars formula n <- 15L mat <- allmultinom(n) nrow(mat) == choose(n + 3L, 3L) # Should be TRUE# Example 1: n = 2 (smallest non-trivial case) allmultinom(2) # Example 2: n = 10 (typical rare-disease PoC group size) mat <- allmultinom(10) nrow(mat) # Should be choose(13, 3) = 286 all(rowSums(mat) == 10) # Every row must sum to n # Example 3: n = 0 (edge case - only the all-zero row) allmultinom(0) # Example 4: Verify column names colnames(allmultinom(5)) # Example 5: Row counts match the stars-and-bars formula n <- 15L mat <- allmultinom(n) nrow(mat) == choose(n + 3L, 3L) # Should be TRUE
Computes the optimal Go threshold and NoGo
threshold for a single binary endpoint by
searching over a grid of candidate values. The two thresholds are
calibrated independently under separate scenarios:
is the smallest value in
gamma_grid such that the marginal Go probability
is strictly
less than target_go under the Go-calibration scenario
(pi_t_go, pi_c_go); typically the Null scenario.
is the smallest value in
gamma_grid such that the marginal NoGo probability
is strictly
less than target_nogo under the NoGo-calibration
scenario (pi_t_nogo, pi_c_nogo); typically the
Alternative scenario.
Here
and
for prob = 'posterior', consistent with the decision rule in
pbayesdecisionprob1bin.
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) )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) )
prob |
A character string specifying the probability type.
Must be |
design |
A character string specifying the trial design.
Must be |
theta_TV |
A numeric scalar in |
theta_MAV |
A numeric scalar in |
theta_NULL |
A numeric scalar in |
pi_t_go |
A numeric scalar in |
pi_c_go |
A numeric scalar in |
pi_t_nogo |
A numeric scalar in |
pi_c_nogo |
A numeric scalar in |
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. |
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
|
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 |
ne_t |
A positive integer giving the number of patients in the
treatment group of the external data set. Required when
|
ne_c |
A positive integer giving the number of patients in the
control group of the external data set. Required when
|
ye_t |
A non-negative integer giving the number of responders in the
treatment group of the external data set. Required when
|
ye_c |
A non-negative integer giving the number of responders in the
control group of the external data set. Required when
|
alpha0e_t |
A numeric scalar in |
alpha0e_c |
A numeric scalar in |
gamma_grid |
A numeric vector of candidate threshold values in
|
The function uses a two-stage precompute-then-sweep strategy:
Precomputation: All possible outcome pairs
are enumerated. For each pair,
pbayespostpred1bin computes
(lower.tail = FALSE at
theta_TV) and (lower.tail
= TRUE at theta_MAV). This step is independent of
.
Gamma sweep: Marginal probabilities are computed as
weighted sums of binary indicators over the grid:
uses w_go (weights under
pi_t_go, pi_c_go) and the indicator
;
uses w_nogo (weights under pi_t_nogo,
pi_c_nogo) and the indicator
.
Both and are
monotone non-increasing functions of . The optimal
is the smallest grid value
crossing below target_go. The optimal
is also the smallest grid value
crossing below target_nogo: a smaller
makes NoGo harder to trigger (more permissive), so this is the least
restrictive threshold that still controls the false NoGo rate.
A list of class getgamma1bin with the following elements:
Optimal Go threshold: the smallest value in
gamma_grid for which
under the Go-calibration scenario.
NA if no such value exists.
Optimal NoGo threshold: the smallest value in
gamma_grid for which
under the NoGo-calibration scenario.
NA if no such value exists.
Marginal
at the optimal under the Go-calibration
scenario. NA if gamma_go is NA.
Marginal
at the optimal 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 # 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 )# 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 )
Computes the optimal Go threshold and NoGo
threshold for a single continuous endpoint by
searching over a grid of candidate values. The two thresholds are
calibrated independently under separate scenarios:
is the smallest value in
gamma_grid such that the marginal Go probability
is strictly
less than target_go under the Go-calibration scenario
(mu_t_go, mu_c_go, sigma_t_go,
sigma_c_go); typically the Null scenario.
is the smallest value in
gamma_grid such that the marginal NoGo probability
is
strictly less than target_nogo under the NoGo-calibration
scenario (mu_t_nogo, mu_c_nogo, sigma_t_nogo,
sigma_c_nogo); typically the Alternative scenario.
Here
and
for prob = 'posterior', consistent with the decision rule in
pbayesdecisionprob1cont.
getgamma1cont( nsim, prob = "posterior", design = "controlled", prior = "vague", CalcMethod = "NI", theta_TV = NULL, theta_MAV = NULL, theta_NULL = NULL, nMC = NULL, mu_t_go, mu_c_go = NULL, sigma_t_go, sigma_c_go = NULL, mu_t_nogo, mu_c_nogo = NULL, sigma_t_nogo, sigma_c_nogo = NULL, target_go, target_nogo, n_t, n_c = NULL, m_t = NULL, m_c = NULL, kappa0_t = NULL, kappa0_c = NULL, nu0_t = NULL, nu0_c = NULL, mu0_t = NULL, mu0_c = NULL, sigma0_t = NULL, sigma0_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, gamma_grid = seq(0.01, 0.99, by = 0.01), seed )getgamma1cont( nsim, prob = "posterior", design = "controlled", prior = "vague", CalcMethod = "NI", theta_TV = NULL, theta_MAV = NULL, theta_NULL = NULL, nMC = NULL, mu_t_go, mu_c_go = NULL, sigma_t_go, sigma_c_go = NULL, mu_t_nogo, mu_c_nogo = NULL, sigma_t_nogo, sigma_c_nogo = NULL, target_go, target_nogo, n_t, n_c = NULL, m_t = NULL, m_c = NULL, kappa0_t = NULL, kappa0_c = NULL, nu0_t = NULL, nu0_c = NULL, mu0_t = NULL, mu0_c = NULL, sigma0_t = NULL, sigma0_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, gamma_grid = seq(0.01, 0.99, by = 0.01), seed )
nsim |
A positive integer giving the number of Monte Carlo simulation replicates used to approximate the operating characteristics. |
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 |
CalcMethod |
A character string specifying the computation method
for |
theta_TV |
A numeric scalar giving the Target Value (TV) threshold
for the treatment effect. Required when |
theta_MAV |
A numeric scalar giving the Minimum Acceptable Value (MAV)
threshold. Must satisfy |
theta_NULL |
A numeric scalar giving the null hypothesis threshold
for the predictive probability. Required when
|
nMC |
A positive integer giving the number of inner Monte Carlo draws
passed to |
mu_t_go |
A numeric scalar giving the true mean for the treatment group under the Go-calibration scenario (typically Null). |
mu_c_go |
A numeric scalar giving the true mean for the control group
under the Go-calibration scenario. Set to |
sigma_t_go |
A positive numeric scalar giving the true standard deviation for the treatment group under the Go-calibration scenario. |
sigma_c_go |
A positive numeric scalar giving the true standard
deviation for the control group under the Go-calibration scenario.
Set to |
mu_t_nogo |
A numeric scalar giving the true mean for the treatment group under the NoGo-calibration scenario (typically Alternative). |
mu_c_nogo |
A numeric scalar giving the true mean for the control
group under the NoGo-calibration scenario. Set to |
sigma_t_nogo |
A positive numeric scalar giving the true standard deviation for the treatment group under the NoGo-calibration scenario. |
sigma_c_nogo |
A positive numeric scalar giving the true standard
deviation for the control group under the NoGo-calibration scenario.
Set to |
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. Required for
|
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 |
A positive numeric scalar giving the prior precision
parameter for the treatment group under the N-Inv-Chi-squared prior.
Required when |
kappa0_c |
A positive numeric scalar giving the prior precision
parameter for the control group. Required when
|
nu0_t |
A positive numeric scalar giving the prior degrees of freedom
for the treatment group under the N-Inv-Chi-squared prior. Required
when |
nu0_c |
A positive numeric scalar giving the prior degrees of freedom
for the control group. Required when |
mu0_t |
A numeric scalar giving the prior mean for the treatment group
under the N-Inv-Chi-squared prior. Required when
|
mu0_c |
A numeric scalar giving the prior mean for the control group
(or the fixed hypothetical control mean for uncontrolled design).
Required when |
sigma0_t |
A positive numeric scalar giving the prior scale parameter
for the treatment group under the N-Inv-Chi-squared prior. Required
when |
sigma0_c |
A positive numeric scalar giving the prior scale parameter
for the control group. Required when |
r |
A positive numeric scalar giving the variance ratio
|
ne_t |
A positive integer giving the number of patients in the
treatment group of the external data set. Required when
|
ne_c |
A positive integer giving the number of patients in the
control group of the external data set. Required when
|
alpha0e_t |
A numeric scalar in |
alpha0e_c |
A numeric scalar in |
bar_ye_t |
A numeric scalar giving the sample mean of the external
treatment group data. Required when |
bar_ye_c |
A numeric scalar giving the sample mean of the external
control group data. Required when |
se_t |
A positive numeric scalar giving the sample standard deviation
of the external treatment group data. Required when |
se_c |
A positive numeric scalar giving the sample standard deviation
of the external control group data. Required when |
gamma_grid |
A numeric vector of candidate 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:
Simulation: nsim datasets are generated
independently for each calibration scenario. For the
Go-calibration scenario, standardised residuals are shifted by
mu_t_go and mu_c_go; for the NoGo-calibration
scenario, by mu_t_nogo and mu_c_nogo.
pbayespostpred1cont is called once per scenario to
obtain (lower.tail = FALSE at
theta_TV) and (lower.tail
= TRUE at theta_MAV).
Gamma sweep: Marginal probabilities are estimated as the
proportion of simulated datasets satisfying the respective
indicator: for
PrGo_grid, and for
PrNoGo_grid. Both are monotone non-increasing in
.
The optimal and
are each the smallest grid value crossing below the respective
target probability.
A list of class getgamma1cont with the following elements:
Optimal Go threshold: the smallest value in
gamma_grid for which
under the Go-calibration scenario.
NA if no such value exists.
Optimal NoGo threshold: the smallest value in
gamma_grid for which
under the NoGo-calibration scenario.
NA if no such value exists.
Marginal
at the optimal under the Go-calibration
scenario. NA if gamma_go is NA.
Marginal
at the optimal 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, vague prior, posterior probability # gamma_go : smallest gamma s.t. Pr(Go) < 0.05 under Null (mu_t = mu_c = 1.0) # gamma_nogo: smallest gamma s.t. Pr(NoGo) < 0.20 under Alt (mu_t = 2.5, mu_c = 1.0) getgamma1cont( nsim = 1000L, prob = 'posterior', design = 'controlled', prior = 'vague', CalcMethod = 'MM', theta_TV = 1.5, theta_MAV = 0.0, theta_NULL = NULL, nMC = NULL, mu_t_go = 1.0, mu_c_go = 1.0, sigma_t_go = 2.0, sigma_c_go = 2.0, mu_t_nogo = 2.5, mu_c_nogo = 1.0, sigma_t_nogo = 2.0, sigma_c_nogo = 2.0, target_go = 0.05, target_nogo = 0.20, n_t = 15L, n_c = 15L, m_t = NULL, m_c = NULL, kappa0_t = NULL, kappa0_c = NULL, nu0_t = NULL, nu0_c = NULL, mu0_t = NULL, mu0_c = NULL, sigma0_t = NULL, sigma0_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, gamma_grid = seq(0.01, 0.99, by = 0.01), seed = 1L ) # Example 2: Uncontrolled design, N-Inv-Chisq prior, posterior probability getgamma1cont( nsim = 1000L, prob = 'posterior', design = 'uncontrolled', prior = 'N-Inv-Chisq', CalcMethod = 'NI', theta_TV = 1.0, theta_MAV = 0.0, theta_NULL = NULL, nMC = NULL, mu_t_go = 1.5, mu_c_go = NULL, sigma_t_go = 1.5, sigma_c_go = NULL, mu_t_nogo = 3.0, mu_c_nogo = NULL, sigma_t_nogo = 1.5, sigma_c_nogo = NULL, target_go = 0.05, target_nogo = 0.20, n_t = 20L, n_c = NULL, m_t = NULL, m_c = NULL, kappa0_t = 2, kappa0_c = NULL, nu0_t = 5, nu0_c = NULL, mu0_t = 3.0, mu0_c = 1.5, sigma0_t = 1.5, sigma0_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, gamma_grid = seq(0.01, 0.99, by = 0.01), seed = 2L ) # Example 3: External design, vague prior, posterior probability getgamma1cont( nsim = 1000L, prob = 'posterior', design = 'external', prior = 'vague', CalcMethod = 'MM', theta_TV = 1.0, theta_MAV = 0.0, theta_NULL = NULL, nMC = NULL, mu_t_go = 1.0, mu_c_go = 1.0, sigma_t_go = 1.5, sigma_c_go = 1.5, mu_t_nogo = 2.5, mu_c_nogo = 1.0, sigma_t_nogo = 1.5, sigma_c_nogo = 1.5, target_go = 0.05, target_nogo = 0.20, n_t = 15L, n_c = 15L, m_t = NULL, m_c = NULL, kappa0_t = NULL, kappa0_c = NULL, nu0_t = NULL, nu0_c = NULL, mu0_t = NULL, mu0_c = NULL, sigma0_t = NULL, sigma0_c = NULL, r = NULL, ne_t = NULL, ne_c = 20L, alpha0e_t = NULL, alpha0e_c = 0.5, bar_ye_t = NULL, bar_ye_c = 0.0, se_t = NULL, se_c = 1.5, gamma_grid = seq(0.01, 0.99, by = 0.01), seed = 4L ) # Example 4: Controlled design, vague prior, predictive probability getgamma1cont( nsim = 1000L, prob = 'predictive', design = 'controlled', prior = 'vague', CalcMethod = 'MM', theta_TV = NULL, theta_MAV = NULL, theta_NULL = 1.0, nMC = NULL, mu_t_go = 1.0, mu_c_go = 1.0, sigma_t_go = 2.0, sigma_c_go = 2.0, mu_t_nogo = 2.5, mu_c_nogo = 1.0, sigma_t_nogo = 2.0, sigma_c_nogo = 2.0, target_go = 0.05, target_nogo = 0.20, n_t = 15L, n_c = 15L, m_t = 50L, m_c = 50L, kappa0_t = NULL, kappa0_c = NULL, nu0_t = NULL, nu0_c = NULL, mu0_t = NULL, mu0_c = NULL, sigma0_t = NULL, sigma0_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, gamma_grid = seq(0.01, 0.99, by = 0.01), seed = 3L ) # Example 5: Uncontrolled design, vague prior, predictive probability getgamma1cont( nsim = 1000L, prob = 'predictive', design = 'uncontrolled', prior = 'vague', CalcMethod = 'MM', theta_TV = NULL, theta_MAV = NULL, theta_NULL = 1.0, nMC = NULL, mu_t_go = 1.0, mu_c_go = NULL, sigma_t_go = 2.0, sigma_c_go = NULL, mu_t_nogo = 2.5, mu_c_nogo = NULL, sigma_t_nogo = 2.0, sigma_c_nogo = NULL, target_go = 0.05, target_nogo = 0.20, n_t = 15L, n_c = NULL, m_t = 50L, m_c = 50L, kappa0_t = NULL, kappa0_c = NULL, nu0_t = NULL, nu0_c = NULL, mu0_t = NULL, mu0_c = 0.0, sigma0_t = NULL, sigma0_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, gamma_grid = seq(0.01, 0.99, by = 0.01), seed = 5L ) # Example 6: External design, vague prior, predictive probability getgamma1cont( nsim = 1000L, prob = 'predictive', design = 'external', prior = 'vague', CalcMethod = 'MM', theta_TV = NULL, theta_MAV = NULL, theta_NULL = 1.0, nMC = NULL, mu_t_go = 1.0, mu_c_go = 1.0, sigma_t_go = 1.5, sigma_c_go = 1.5, mu_t_nogo = 2.5, mu_c_nogo = 1.0, sigma_t_nogo = 1.5, sigma_c_nogo = 1.5, target_go = 0.05, target_nogo = 0.20, n_t = 15L, n_c = 15L, m_t = 50L, m_c = 50L, kappa0_t = NULL, kappa0_c = NULL, nu0_t = NULL, nu0_c = NULL, mu0_t = NULL, mu0_c = NULL, sigma0_t = NULL, sigma0_c = NULL, r = NULL, ne_t = NULL, ne_c = 20L, alpha0e_t = NULL, alpha0e_c = 0.5, bar_ye_t = NULL, bar_ye_c = 0.0, se_t = NULL, se_c = 1.5, gamma_grid = seq(0.01, 0.99, by = 0.01), seed = 6L )# Example 1: Controlled design, vague prior, posterior probability # gamma_go : smallest gamma s.t. Pr(Go) < 0.05 under Null (mu_t = mu_c = 1.0) # gamma_nogo: smallest gamma s.t. Pr(NoGo) < 0.20 under Alt (mu_t = 2.5, mu_c = 1.0) getgamma1cont( nsim = 1000L, prob = 'posterior', design = 'controlled', prior = 'vague', CalcMethod = 'MM', theta_TV = 1.5, theta_MAV = 0.0, theta_NULL = NULL, nMC = NULL, mu_t_go = 1.0, mu_c_go = 1.0, sigma_t_go = 2.0, sigma_c_go = 2.0, mu_t_nogo = 2.5, mu_c_nogo = 1.0, sigma_t_nogo = 2.0, sigma_c_nogo = 2.0, target_go = 0.05, target_nogo = 0.20, n_t = 15L, n_c = 15L, m_t = NULL, m_c = NULL, kappa0_t = NULL, kappa0_c = NULL, nu0_t = NULL, nu0_c = NULL, mu0_t = NULL, mu0_c = NULL, sigma0_t = NULL, sigma0_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, gamma_grid = seq(0.01, 0.99, by = 0.01), seed = 1L ) # Example 2: Uncontrolled design, N-Inv-Chisq prior, posterior probability getgamma1cont( nsim = 1000L, prob = 'posterior', design = 'uncontrolled', prior = 'N-Inv-Chisq', CalcMethod = 'NI', theta_TV = 1.0, theta_MAV = 0.0, theta_NULL = NULL, nMC = NULL, mu_t_go = 1.5, mu_c_go = NULL, sigma_t_go = 1.5, sigma_c_go = NULL, mu_t_nogo = 3.0, mu_c_nogo = NULL, sigma_t_nogo = 1.5, sigma_c_nogo = NULL, target_go = 0.05, target_nogo = 0.20, n_t = 20L, n_c = NULL, m_t = NULL, m_c = NULL, kappa0_t = 2, kappa0_c = NULL, nu0_t = 5, nu0_c = NULL, mu0_t = 3.0, mu0_c = 1.5, sigma0_t = 1.5, sigma0_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, gamma_grid = seq(0.01, 0.99, by = 0.01), seed = 2L ) # Example 3: External design, vague prior, posterior probability getgamma1cont( nsim = 1000L, prob = 'posterior', design = 'external', prior = 'vague', CalcMethod = 'MM', theta_TV = 1.0, theta_MAV = 0.0, theta_NULL = NULL, nMC = NULL, mu_t_go = 1.0, mu_c_go = 1.0, sigma_t_go = 1.5, sigma_c_go = 1.5, mu_t_nogo = 2.5, mu_c_nogo = 1.0, sigma_t_nogo = 1.5, sigma_c_nogo = 1.5, target_go = 0.05, target_nogo = 0.20, n_t = 15L, n_c = 15L, m_t = NULL, m_c = NULL, kappa0_t = NULL, kappa0_c = NULL, nu0_t = NULL, nu0_c = NULL, mu0_t = NULL, mu0_c = NULL, sigma0_t = NULL, sigma0_c = NULL, r = NULL, ne_t = NULL, ne_c = 20L, alpha0e_t = NULL, alpha0e_c = 0.5, bar_ye_t = NULL, bar_ye_c = 0.0, se_t = NULL, se_c = 1.5, gamma_grid = seq(0.01, 0.99, by = 0.01), seed = 4L ) # Example 4: Controlled design, vague prior, predictive probability getgamma1cont( nsim = 1000L, prob = 'predictive', design = 'controlled', prior = 'vague', CalcMethod = 'MM', theta_TV = NULL, theta_MAV = NULL, theta_NULL = 1.0, nMC = NULL, mu_t_go = 1.0, mu_c_go = 1.0, sigma_t_go = 2.0, sigma_c_go = 2.0, mu_t_nogo = 2.5, mu_c_nogo = 1.0, sigma_t_nogo = 2.0, sigma_c_nogo = 2.0, target_go = 0.05, target_nogo = 0.20, n_t = 15L, n_c = 15L, m_t = 50L, m_c = 50L, kappa0_t = NULL, kappa0_c = NULL, nu0_t = NULL, nu0_c = NULL, mu0_t = NULL, mu0_c = NULL, sigma0_t = NULL, sigma0_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, gamma_grid = seq(0.01, 0.99, by = 0.01), seed = 3L ) # Example 5: Uncontrolled design, vague prior, predictive probability getgamma1cont( nsim = 1000L, prob = 'predictive', design = 'uncontrolled', prior = 'vague', CalcMethod = 'MM', theta_TV = NULL, theta_MAV = NULL, theta_NULL = 1.0, nMC = NULL, mu_t_go = 1.0, mu_c_go = NULL, sigma_t_go = 2.0, sigma_c_go = NULL, mu_t_nogo = 2.5, mu_c_nogo = NULL, sigma_t_nogo = 2.0, sigma_c_nogo = NULL, target_go = 0.05, target_nogo = 0.20, n_t = 15L, n_c = NULL, m_t = 50L, m_c = 50L, kappa0_t = NULL, kappa0_c = NULL, nu0_t = NULL, nu0_c = NULL, mu0_t = NULL, mu0_c = 0.0, sigma0_t = NULL, sigma0_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, gamma_grid = seq(0.01, 0.99, by = 0.01), seed = 5L ) # Example 6: External design, vague prior, predictive probability getgamma1cont( nsim = 1000L, prob = 'predictive', design = 'external', prior = 'vague', CalcMethod = 'MM', theta_TV = NULL, theta_MAV = NULL, theta_NULL = 1.0, nMC = NULL, mu_t_go = 1.0, mu_c_go = 1.0, sigma_t_go = 1.5, sigma_c_go = 1.5, mu_t_nogo = 2.5, mu_c_nogo = 1.0, sigma_t_nogo = 1.5, sigma_c_nogo = 1.5, target_go = 0.05, target_nogo = 0.20, n_t = 15L, n_c = 15L, m_t = 50L, m_c = 50L, kappa0_t = NULL, kappa0_c = NULL, nu0_t = NULL, nu0_c = NULL, mu0_t = NULL, mu0_c = NULL, sigma0_t = NULL, sigma0_c = NULL, r = NULL, ne_t = NULL, ne_c = 20L, alpha0e_t = NULL, alpha0e_c = 0.5, bar_ye_t = NULL, bar_ye_c = 0.0, se_t = NULL, se_c = 1.5, gamma_grid = seq(0.01, 0.99, by = 0.01), seed = 6L )
Computes the optimal Go threshold and NoGo
threshold for two binary endpoints by
searching over a two-dimensional grid of candidate value pairs. The two
thresholds are calibrated independently under separate scenarios:
is the smallest value in
gamma_go_grid such that the worst-case marginal Go
probability over all 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.
is the smallest value in
gamma_nogo_grid such that the worst-case marginal NoGo
probability over all 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.
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) )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) )
prob |
A character string specifying the probability type.
Must be |
design |
A character string specifying the trial design.
Must be |
GoRegions |
An integer vector of region indices (subset of
|
NoGoRegions |
An integer vector of region indices that constitute
the NoGo region. Must be disjoint from |
pi_t1_go |
A numeric scalar in |
pi_t2_go |
A numeric scalar in |
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 |
pi_c2_go |
A numeric scalar in |
rho_c_go |
A numeric scalar giving the within-group correlation in
the control group under the Go-calibration scenario. Required for
|
pi_t1_nogo |
A numeric scalar in |
pi_t2_nogo |
A numeric scalar in |
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 |
pi_c2_nogo |
A numeric scalar in |
rho_c_nogo |
A numeric scalar giving the within-group correlation 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. |
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_10 |
A positive numeric scalar; see |
a_t_11 |
A positive numeric scalar; see |
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_10 |
A positive numeric scalar; see |
a_c_11 |
A positive numeric scalar; see |
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 |
z00 |
A non-negative integer giving the hypothetical control count
for pattern (0,0). Required when
|
z01 |
A non-negative integer; see |
z10 |
A non-negative integer; see |
z11 |
A non-negative integer; see |
xe_t_00 |
A non-negative integer giving the external treatment group
count for pattern (0,0). Required when
|
xe_t_01 |
A non-negative integer; see |
xe_t_10 |
A non-negative integer; see |
xe_t_11 |
A non-negative integer; see |
xe_c_00 |
A non-negative integer giving the external control group
count for pattern (0,0). Required when
|
xe_c_01 |
A non-negative integer; see |
xe_c_10 |
A non-negative integer; see |
xe_c_11 |
A non-negative integer; see |
alpha0e_t |
A numeric scalar in |
alpha0e_c |
A numeric scalar in |
nMC |
A positive integer giving the number of Dirichlet draws used
to evaluate region probabilities for each count combination in
Stage 1. Default is |
gamma_go_grid |
A numeric vector of candidate Go threshold values
in |
gamma_nogo_grid |
A numeric vector of candidate NoGo threshold
values in |
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
enumerated by allmultinom. The resulting region probability
vector is summed over GoRegions and NoGoRegions to obtain
and . These are independent
of the calibration scenario; only the multinomial weights differ.
Stage 2 (gamma sweep): For each pair
in the
two-dimensional grid, operating characteristics are computed separately
under each calibration scenario using the respective multinomial weights:
Stage 3 (optimal threshold selection): For each candidate
, the worst-case over all
in gamma_nogo_grid is computed; the
optimal is the smallest grid value for
which this worst-case probability is less than target_go.
Analogously, the optimal is the
smallest grid value for which the worst-case
is less than target_nogo.
A list of class getgamma2bin with the following elements:
Optimal Go threshold: the smallest value in
gamma_go_grid for which the marginal
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
under the
NoGo-calibration scenario. NA if no such value exists.
Marginal at
gamma_go under the Go-calibration scenario.
NA if gamma_go is NA.
Marginal 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 # 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) )# 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) )
Computes the optimal Go threshold and NoGo
threshold for two continuous endpoints by
searching independently over candidate threshold grids. The two
thresholds are calibrated marginally under separate scenarios:
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.
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 )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
(and
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 matrix of region
probabilities. The probabilities are summed over GoRegions
(for the Go scenario) and NoGoRegions (for the NoGo scenario)
to obtain and ,
independent of the decision thresholds.
Stage 2 (gamma sweep): For each pair
in the
two-dimensional grid, operating characteristics are computed separately
under each calibration scenario:
Stage 3 (optimal threshold selection): For each candidate
, the worst-case over
all in gamma_nogo_grid is computed;
the optimal is the smallest grid value
for which this worst-case probability is less than target_go.
Analogously, the optimal is the
smallest grid value for which the worst-case
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
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
under the
NoGo-calibration scenario. NA if no such value exists.
Marginal at
gamma_go under the Go-calibration scenario.
NA if gamma_go is NA.
Marginal 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 )# 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 )
Converts the parameterisation into the
four-cell joint probability vector
for a bivariate binary
outcome in group . The conversion uses the standard
moment-matching identity for the Pearson correlation of two Bernoulli
variables, and checks that the requested correlation is feasible for the
supplied marginal rates.
getjointbin(pi1, pi2, rho, tol = 1e-10)getjointbin(pi1, pi2, rho, tol = 1e-10)
pi1 |
A single numeric value in |
pi2 |
A single numeric value in |
rho |
A single numeric value giving the Pearson correlation
( |
tol |
A single positive numeric value specifying the tolerance used
when checking whether |
For a bivariate binary outcome of patient
() in group with marginal success
probabilities and
, the Pearson correlation is
Solving for gives
from which the remaining probabilities follow:
For all four cell probabilities to lie in [0, 1], the correlation
must satisfy
The function raises an error if rho falls outside this range
(subject to tol).
A named numeric vector of length 4 with elements
p00, p01, p10, p11, where
p_lm = Pr(Endpoint 1 = l, Endpoint 2 = m) for
.
All elements are non-negative and sum to 1.
# Example 1: Independent endpoints (rho = 0) getjointbin(pi1 = 0.3, pi2 = 0.4, rho = 0.0) # Example 2: Positive correlation getjointbin(pi1 = 0.3, pi2 = 0.4, rho = 0.3) # Example 3: Negative correlation getjointbin(pi1 = 0.3, pi2 = 0.4, rho = -0.2) # Example 4: Verify cell probabilities sum to 1 p <- getjointbin(pi1 = 0.25, pi2 = 0.35, rho = 0.1) sum(p) # Should be 1 # Example 5: Verify marginal recovery p <- getjointbin(pi1 = 0.25, pi2 = 0.35, rho = 0.1) p["p10"] + p["p11"] # Should equal pi1 = 0.25 p["p01"] + p["p11"] # Should equal pi2 = 0.35# Example 1: Independent endpoints (rho = 0) getjointbin(pi1 = 0.3, pi2 = 0.4, rho = 0.0) # Example 2: Positive correlation getjointbin(pi1 = 0.3, pi2 = 0.4, rho = 0.3) # Example 3: Negative correlation getjointbin(pi1 = 0.3, pi2 = 0.4, rho = -0.2) # Example 4: Verify cell probabilities sum to 1 p <- getjointbin(pi1 = 0.25, pi2 = 0.35, rho = 0.1) sum(p) # Should be 1 # Example 5: Verify marginal recovery p <- getjointbin(pi1 = 0.25, pi2 = 0.35, rho = 0.1) p["p10"] + p["p11"] # Should equal pi1 = 0.25 p["p01"] + p["p11"] # Should equal pi2 = 0.35
Evaluates operating characteristics (Go, NoGo, Gray probabilities) for binary-outcome clinical trials under the Bayesian framework by enumerating all possible trial outcomes. The function supports controlled, uncontrolled, and external designs.
pbayesdecisionprob1bin( prob = "posterior", design = "controlled", theta_TV = NULL, theta_MAV = NULL, theta_NULL = NULL, gamma_go, gamma_nogo, pi_t, pi_c = NULL, 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, error_if_Miss = TRUE, Gray_inc_Miss = FALSE )pbayesdecisionprob1bin( prob = "posterior", design = "controlled", theta_TV = NULL, theta_MAV = NULL, theta_NULL = NULL, gamma_go, gamma_nogo, pi_t, pi_c = NULL, 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, error_if_Miss = TRUE, Gray_inc_Miss = FALSE )
prob |
A character string specifying the probability type.
Must be |
design |
A character string specifying the trial design.
Must be |
theta_TV |
A numeric scalar giving the target value (TV) threshold used for
the Go decision when |
theta_MAV |
A numeric scalar giving the minimum acceptable value (MAV)
threshold used for the NoGo decision when |
theta_NULL |
A numeric scalar giving the null hypothesis threshold used for
both Go and NoGo decisions when |
gamma_go |
A numeric scalar in |
gamma_nogo |
A numeric scalar in |
pi_t |
A numeric value or vector giving the true response probability(s) for
the treatment group used to evaluate operating characteristics. Each element
must be in |
pi_c |
A numeric value or vector giving the true response probability(s) for
the control group. For |
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 |
a_t |
A positive numeric scalar giving the first shape parameter (alpha) of the prior Beta distribution for the treatment group. |
a_c |
A positive numeric scalar giving the first shape parameter (alpha) of the prior Beta distribution for the control group. |
b_t |
A positive numeric scalar giving the second shape parameter (beta) of the prior Beta distribution for the treatment group. |
b_c |
A positive numeric scalar giving the second shape parameter (beta) of the prior Beta distribution for the control group. |
z |
A non-negative integer giving the hypothetical number of responders
in the control group. Required when |
m_t |
A positive integer giving the number of patients in the
treatment group for the future trial. Required when
|
m_c |
A positive integer giving the number of patients in the
control group for the future trial. Required when
|
ne_t |
A positive integer giving the number of patients in the
treatment group of the external data set. Required when
|
ne_c |
A positive integer giving the number of patients in the
control group of the external data set. Required when
|
ye_t |
A non-negative integer giving the number of responders in the
treatment group of the external data set. Required when
|
ye_c |
A non-negative integer giving the number of responders in the
control group of the external data set. Required when
|
alpha0e_t |
A numeric scalar in |
alpha0e_c |
A numeric scalar in |
error_if_Miss |
A logical scalar; if |
Gray_inc_Miss |
A logical scalar; if |
Operating characteristics are computed by exact enumeration:
All possible outcome pairs with
and (or fixed at for uncontrolled) are
evaluated.
For each pair, pbayespostpred1bin computes the posterior or predictive
probability at both thresholds (TV/MAV or NULL).
Outcomes are classified into Go, NoGo, Miss, or Gray:
Go: AND
NoGo: AND
Miss: both Go and NoGo criteria met simultaneously
Gray: neither Go nor NoGo criteria met
Each outcome is weighted by its binomial probability under the true rates.
A data frame with one row per pi_t scenario and columns:
True treatment response probability.
True control response probability (omitted for uncontrolled design).
Probability of making a Go decision.
Probability of making a Gray (inconclusive) decision.
Probability of making a NoGo decision.
(Optional) Probability where Go and NoGo criteria are simultaneously
met. Included when error_if_Miss = FALSE and
Gray_inc_Miss = FALSE.
The returned object has S3 class pbayesdecisionprob1bin with an associated
print method.
# Example 1: Controlled design with posterior probability pbayesdecisionprob1bin( prob = 'posterior', design = 'controlled', theta_TV = 0.4, theta_MAV = 0.2, theta_NULL = NULL, gamma_go = 0.8, gamma_nogo = 0.2, pi_t = c(0.2, 0.4, 0.6, 0.8), pi_c = rep(0.2, 4), n_t = 12, n_c = 12, 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, error_if_Miss = TRUE, Gray_inc_Miss = FALSE ) # Example 2: Uncontrolled design with hypothetical control pbayesdecisionprob1bin( prob = 'posterior', design = 'uncontrolled', theta_TV = 0.30, theta_MAV = 0.15, theta_NULL = NULL, gamma_go = 0.75, gamma_nogo = 0.25, pi_t = c(0.3, 0.5, 0.7), pi_c = NULL, n_t = 15, n_c = 15, a_t = 0.5, a_c = 0.5, b_t = 0.5, b_c = 0.5, z = 5, m_t = NULL, m_c = NULL, ne_t = NULL, ne_c = NULL, ye_t = NULL, ye_c = NULL, alpha0e_t = NULL, alpha0e_c = NULL, error_if_Miss = TRUE, Gray_inc_Miss = FALSE ) # Example 3: External design with 50 percent power prior borrowing pbayesdecisionprob1bin( prob = 'posterior', design = 'external', theta_TV = 0.4, theta_MAV = 0.2, theta_NULL = NULL, gamma_go = 0.8, gamma_nogo = 0.2, pi_t = c(0.2, 0.4, 0.6, 0.8), pi_c = rep(0.2, 4), n_t = 12, n_c = 12, 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 = 15, ne_c = 15, ye_t = 6, ye_c = 4, alpha0e_t = 0.5, alpha0e_c = 0.5, error_if_Miss = TRUE, Gray_inc_Miss = FALSE ) # Example 4: Posterior predictive probability for controlled design pbayesdecisionprob1bin( prob = 'predictive', design = 'controlled', theta_TV = NULL, theta_MAV = NULL, theta_NULL = 0, gamma_go = 0.9, gamma_nogo = 0.3, pi_t = c(0.2, 0.4, 0.6, 0.8), pi_c = rep(0.2, 4), n_t = 12, n_c = 12, a_t = 0.5, a_c = 0.5, b_t = 0.5, b_c = 0.5, z = NULL, m_t = 30, m_c = 30, ne_t = NULL, ne_c = NULL, ye_t = NULL, ye_c = NULL, alpha0e_t = NULL, alpha0e_c = NULL, error_if_Miss = TRUE, Gray_inc_Miss = FALSE ) # Example 5: Uncontrolled design with posterior predictive probability pbayesdecisionprob1bin( prob = 'predictive', design = 'uncontrolled', theta_TV = NULL, theta_MAV = NULL, theta_NULL = 0, gamma_go = 0.75, gamma_nogo = 0.25, pi_t = c(0.3, 0.5, 0.7), pi_c = NULL, n_t = 15, n_c = 15, a_t = 0.5, a_c = 0.5, b_t = 0.5, b_c = 0.5, z = 5, m_t = 30, m_c = 30, ne_t = NULL, ne_c = NULL, ye_t = NULL, ye_c = NULL, alpha0e_t = NULL, alpha0e_c = NULL, error_if_Miss = TRUE, Gray_inc_Miss = FALSE ) # Example 6: External design with posterior predictive probability pbayesdecisionprob1bin( prob = 'predictive', design = 'external', theta_TV = NULL, theta_MAV = NULL, theta_NULL = 0, gamma_go = 0.9, gamma_nogo = 0.3, pi_t = c(0.2, 0.4, 0.6, 0.8), pi_c = rep(0.2, 4), n_t = 12, n_c = 12, a_t = 0.5, a_c = 0.5, b_t = 0.5, b_c = 0.5, z = NULL, m_t = 30, m_c = 30, ne_t = 15, ne_c = 15, ye_t = 6, ye_c = 4, alpha0e_t = 0.5, alpha0e_c = 0.5, error_if_Miss = TRUE, Gray_inc_Miss = FALSE )# Example 1: Controlled design with posterior probability pbayesdecisionprob1bin( prob = 'posterior', design = 'controlled', theta_TV = 0.4, theta_MAV = 0.2, theta_NULL = NULL, gamma_go = 0.8, gamma_nogo = 0.2, pi_t = c(0.2, 0.4, 0.6, 0.8), pi_c = rep(0.2, 4), n_t = 12, n_c = 12, 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, error_if_Miss = TRUE, Gray_inc_Miss = FALSE ) # Example 2: Uncontrolled design with hypothetical control pbayesdecisionprob1bin( prob = 'posterior', design = 'uncontrolled', theta_TV = 0.30, theta_MAV = 0.15, theta_NULL = NULL, gamma_go = 0.75, gamma_nogo = 0.25, pi_t = c(0.3, 0.5, 0.7), pi_c = NULL, n_t = 15, n_c = 15, a_t = 0.5, a_c = 0.5, b_t = 0.5, b_c = 0.5, z = 5, m_t = NULL, m_c = NULL, ne_t = NULL, ne_c = NULL, ye_t = NULL, ye_c = NULL, alpha0e_t = NULL, alpha0e_c = NULL, error_if_Miss = TRUE, Gray_inc_Miss = FALSE ) # Example 3: External design with 50 percent power prior borrowing pbayesdecisionprob1bin( prob = 'posterior', design = 'external', theta_TV = 0.4, theta_MAV = 0.2, theta_NULL = NULL, gamma_go = 0.8, gamma_nogo = 0.2, pi_t = c(0.2, 0.4, 0.6, 0.8), pi_c = rep(0.2, 4), n_t = 12, n_c = 12, 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 = 15, ne_c = 15, ye_t = 6, ye_c = 4, alpha0e_t = 0.5, alpha0e_c = 0.5, error_if_Miss = TRUE, Gray_inc_Miss = FALSE ) # Example 4: Posterior predictive probability for controlled design pbayesdecisionprob1bin( prob = 'predictive', design = 'controlled', theta_TV = NULL, theta_MAV = NULL, theta_NULL = 0, gamma_go = 0.9, gamma_nogo = 0.3, pi_t = c(0.2, 0.4, 0.6, 0.8), pi_c = rep(0.2, 4), n_t = 12, n_c = 12, a_t = 0.5, a_c = 0.5, b_t = 0.5, b_c = 0.5, z = NULL, m_t = 30, m_c = 30, ne_t = NULL, ne_c = NULL, ye_t = NULL, ye_c = NULL, alpha0e_t = NULL, alpha0e_c = NULL, error_if_Miss = TRUE, Gray_inc_Miss = FALSE ) # Example 5: Uncontrolled design with posterior predictive probability pbayesdecisionprob1bin( prob = 'predictive', design = 'uncontrolled', theta_TV = NULL, theta_MAV = NULL, theta_NULL = 0, gamma_go = 0.75, gamma_nogo = 0.25, pi_t = c(0.3, 0.5, 0.7), pi_c = NULL, n_t = 15, n_c = 15, a_t = 0.5, a_c = 0.5, b_t = 0.5, b_c = 0.5, z = 5, m_t = 30, m_c = 30, ne_t = NULL, ne_c = NULL, ye_t = NULL, ye_c = NULL, alpha0e_t = NULL, alpha0e_c = NULL, error_if_Miss = TRUE, Gray_inc_Miss = FALSE ) # Example 6: External design with posterior predictive probability pbayesdecisionprob1bin( prob = 'predictive', design = 'external', theta_TV = NULL, theta_MAV = NULL, theta_NULL = 0, gamma_go = 0.9, gamma_nogo = 0.3, pi_t = c(0.2, 0.4, 0.6, 0.8), pi_c = rep(0.2, 4), n_t = 12, n_c = 12, a_t = 0.5, a_c = 0.5, b_t = 0.5, b_c = 0.5, z = NULL, m_t = 30, m_c = 30, ne_t = 15, ne_c = 15, ye_t = 6, ye_c = 4, alpha0e_t = 0.5, alpha0e_c = 0.5, error_if_Miss = TRUE, Gray_inc_Miss = FALSE )
Evaluates Go/NoGo/Gray decision probabilities for a single continuous endpoint via Monte Carlo simulation. Supports controlled (parallel control), uncontrolled (single-arm with informative priors), and external (power prior borrowing) designs with both posterior and predictive probability approaches.
pbayesdecisionprob1cont( nsim, prob, design, prior, CalcMethod, theta_TV = NULL, theta_MAV = NULL, theta_NULL = NULL, nMC = NULL, gamma_go, gamma_nogo, n_t, n_c = NULL, m_t = NULL, m_c = NULL, kappa0_t = NULL, kappa0_c = NULL, nu0_t = NULL, nu0_c = NULL, mu0_t = NULL, mu0_c = NULL, sigma0_t = NULL, sigma0_c = NULL, mu_t, mu_c = NULL, sigma_t, sigma_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, error_if_Miss = TRUE, Gray_inc_Miss = FALSE, seed )pbayesdecisionprob1cont( nsim, prob, design, prior, CalcMethod, theta_TV = NULL, theta_MAV = NULL, theta_NULL = NULL, nMC = NULL, gamma_go, gamma_nogo, n_t, n_c = NULL, m_t = NULL, m_c = NULL, kappa0_t = NULL, kappa0_c = NULL, nu0_t = NULL, nu0_c = NULL, mu0_t = NULL, mu0_c = NULL, sigma0_t = NULL, sigma0_c = NULL, mu_t, mu_c = NULL, sigma_t, sigma_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, error_if_Miss = TRUE, Gray_inc_Miss = FALSE, seed )
nsim |
A positive integer specifying the number of Monte Carlo simulation replicates. |
prob |
A character string specifying the probability type: |
design |
A character string specifying the trial design: |
prior |
A character string specifying the prior distribution: |
CalcMethod |
A character string specifying the computation method: |
theta_TV |
A numeric value representing the target value (TV) threshold for the
Go decision. Required if |
theta_MAV |
A numeric value representing the minimum acceptable value (MAV) threshold
for the NoGo decision. Required if |
theta_NULL |
A numeric value representing the null hypothesis threshold.
Required if |
nMC |
A positive integer specifying the number of Monte Carlo draws for computing
posterior probabilities. Required if |
gamma_go |
A numeric scalar in |
gamma_nogo |
A numeric scalar in |
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 proof-of-concept (PoC) trial. Required for
|
m_t |
A positive integer representing the future sample size for the
treatment group. Required if |
m_c |
A positive integer representing the future sample size for the control group.
Required if |
kappa0_t |
A positive numeric value representing the prior hyperparameter kappa for
the treatment group. Required if |
kappa0_c |
A positive numeric value representing the prior hyperparameter kappa for
the control group. Required if |
nu0_t |
A positive numeric value representing the prior hyperparameter nu for
the treatment group. Required if |
nu0_c |
A positive numeric value representing the prior hyperparameter nu for
the control group. Required if |
mu0_t |
A numeric value representing the prior mean for the treatment group. Required if
|
mu0_c |
A numeric value representing the prior mean for the control group. For
|
sigma0_t |
A positive numeric value representing the prior standard deviation for
the treatment group. Required if |
sigma0_c |
A positive numeric value representing the prior standard deviation for
the control group. Required if |
mu_t |
A numeric value representing the true mean for the treatment group in the simulation. |
mu_c |
A numeric value representing the true mean for the control group in the simulation.
For uncontrolled design, this represents the historical control mean.
Set to |
sigma_t |
A positive numeric value representing the true standard deviation for the treatment group in the simulation. |
sigma_c |
A positive numeric value representing the true standard deviation
for the control group in the simulation. For uncontrolled design, this represents
the historical control standard deviation.
Set to |
r |
A positive numeric value representing the variance scaling factor that allows
the scale of hypothetical control to be different from treatment. Specifically,
|
ne_t |
A positive integer representing the number of patients in the treatment group for
the external data. Required if |
ne_c |
A positive integer representing the number of patients in the control group for
the external data. Required if |
alpha0e_t |
A numeric value in |
alpha0e_c |
A numeric value in |
bar_ye_t |
A numeric value representing the sample mean of the external data
for the treatment group. Required if |
bar_ye_c |
A numeric value representing the sample mean of the external data
for the control group. Required if |
se_t |
A positive numeric value representing the sample standard deviation
of the external data for the treatment group. Required if |
se_c |
A positive numeric value representing the sample standard deviation
of the external data for the control group. Required if |
error_if_Miss |
A logical value; if |
Gray_inc_Miss |
A logical value; if |
seed |
A numeric value representing the seed number for reproducible random number generation. |
The function performs Monte Carlo simulation to evaluate operating characteristics by:
Generating random trial data based on specified true parameters
Computing posterior or predictive probabilities for each simulated trial
Classifying each trial as Go, NoGo, or Gray based on decision thresholds
Posterior parameter calculations (mu.t1, mu.t2, sd.t1, sd.t2, nu.t1, nu.t2) are fully vectorized over the nsim simulated datasets. pbayespostpred1cont is called twice (once per threshold), with each call receiving vectors of length nsim and returning a vector of nsim probabilities - no inner loop over simulation replicates is required.
For external designs, power priors are incorporated using exact conjugate representation:
Power priors for normal data are mathematically equivalent to Normal-Inverse-Chi-squared distributions
This enables closed-form computation without MCMC sampling
Alpha parameters control the degree of borrowing (0 = no borrowing, 1 = full borrowing)
Decision rules:
Go: gGo >= gamma_go and gNoGo < gamma_nogo
NoGo: gGo < gamma_go and gNoGo >= gamma_nogo
Gray: neither Go nor NoGo criterion is met
Miss: both Go and NoGo criteria are met simultaneously
Handling Miss probability:
When error_if_Miss = TRUE (default): Function stops with error if
Miss probability > 0, prompting reconsideration of thresholds
When error_if_Miss = FALSE and Gray_inc_Miss = TRUE: Miss
probability is added to Gray probability
When error_if_Miss = FALSE and Gray_inc_Miss = FALSE: Miss
probability is reported as a separate category
The function can be used for:
Controlled design: Two-arm randomized trial
Uncontrolled design: Single-arm trial with informative priors (historical control)
External design: Incorporating historical data through power priors
A data frame containing the true means for both groups and the Go, NoGo, and
Gray probabilities. When error_if_Miss = FALSE and Gray_inc_Miss = FALSE,
Miss probability is also included as a separate column. For uncontrolled design,
only mu_t is included (not mu_c).
# Example 1: Controlled design with vague prior and NI method # (default: error_if_Miss = TRUE, Gray_inc_Miss = FALSE) pbayesdecisionprob1cont( nsim = 100, prob = 'posterior', design = 'controlled', prior = 'vague', CalcMethod = 'NI', theta_TV = 1.5, theta_MAV = -0.5, theta_NULL = NULL, nMC = NULL, gamma_go = 0.7, gamma_nogo = 0.2, n_t = 15, n_c = 15, m_t = NULL, m_c = NULL, kappa0_t = NULL, kappa0_c = NULL, nu0_t = NULL, nu0_c = NULL, mu0_t = NULL, mu0_c = NULL, sigma0_t = NULL, sigma0_c = NULL, mu_t = 3, mu_c = 1, sigma_t = 1.2, sigma_c = 1.1, 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, error_if_Miss = TRUE, Gray_inc_Miss = FALSE, seed = 2 ) # Example 2: Uncontrolled design with informative prior pbayesdecisionprob1cont( nsim = 100, prob = 'posterior', design = 'uncontrolled', prior = 'N-Inv-Chisq', CalcMethod = 'NI', theta_TV = 1.0, theta_MAV = 0.0, theta_NULL = NULL, nMC = NULL, gamma_go = 0.8, gamma_nogo = 0.2, n_t = 20, n_c = NULL, m_t = NULL, m_c = NULL, kappa0_t = 2, kappa0_c = NULL, nu0_t = 5, nu0_c = NULL, mu0_t = 3.0, mu0_c = 1.5, sigma0_t = 1.5, sigma0_c = NULL, mu_t = 3.5, mu_c = NULL, sigma_t = 1.3, sigma_c = NULL, r = 1, 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, error_if_Miss = TRUE, Gray_inc_Miss = FALSE, seed = 3 ) # Example 3: External design with control data using MM approximation pbayesdecisionprob1cont( nsim = 100, prob = 'posterior', design = 'external', prior = 'vague', CalcMethod = 'MM', theta_TV = 1.0, theta_MAV = 0.0, theta_NULL = NULL, nMC = NULL, gamma_go = 0.8, gamma_nogo = 0.2, n_t = 12, n_c = 12, m_t = NULL, m_c = NULL, kappa0_t = NULL, kappa0_c = NULL, nu0_t = NULL, nu0_c = NULL, mu0_t = NULL, mu0_c = NULL, sigma0_t = NULL, sigma0_c = NULL, mu_t = 2, mu_c = 0, sigma_t = 1, sigma_c = 1, r = NULL, ne_t = NULL, ne_c = 20, alpha0e_t = NULL, alpha0e_c = 0.5, bar_ye_t = NULL, bar_ye_c = 0, se_t = NULL, se_c = 1, error_if_Miss = TRUE, Gray_inc_Miss = FALSE, seed = 4 ) # Example 4: Controlled design with predictive probability pbayesdecisionprob1cont( nsim = 100, prob = 'predictive', design = 'controlled', prior = 'N-Inv-Chisq', CalcMethod = 'NI', theta_TV = NULL, theta_MAV = NULL, theta_NULL = 2.0, nMC = NULL, gamma_go = 0.75, gamma_nogo = 0.35, n_t = 15, n_c = 15, m_t = 50, m_c = 50, kappa0_t = 3, kappa0_c = 3, nu0_t = 4, nu0_c = 4, mu0_t = 3.5, mu0_c = 1.5, sigma0_t = 1.5, sigma0_c = 1.5, mu_t = 3.2, mu_c = 1.3, sigma_t = 1.4, sigma_c = 1.2, 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, error_if_Miss = TRUE, Gray_inc_Miss = FALSE, seed = 5 ) # Example 5: Uncontrolled design with predictive probability pbayesdecisionprob1cont( nsim = 100, prob = 'predictive', design = 'uncontrolled', prior = 'vague', CalcMethod = 'NI', theta_TV = NULL, theta_MAV = NULL, theta_NULL = 1.0, nMC = NULL, gamma_go = 0.75, gamma_nogo = 0.35, n_t = 20, n_c = NULL, m_t = 40, m_c = 40, kappa0_t = NULL, kappa0_c = NULL, nu0_t = NULL, nu0_c = NULL, mu0_t = NULL, mu0_c = 1.5, sigma0_t = NULL, sigma0_c = NULL, mu_t = 3, mu_c = NULL, sigma_t = 1.3, sigma_c = NULL, r = 1, 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, error_if_Miss = TRUE, Gray_inc_Miss = FALSE, seed = 9 ) # Example 6: External design with predictive probability using MC method pbayesdecisionprob1cont( nsim = 100, prob = 'predictive', design = 'external', prior = 'vague', CalcMethod = 'MC', theta_TV = NULL, theta_MAV = NULL, theta_NULL = 1.5, nMC = 5000, gamma_go = 0.7, gamma_nogo = 0.4, n_t = 12, n_c = 12, m_t = 30, m_c = 30, kappa0_t = NULL, kappa0_c = NULL, nu0_t = NULL, nu0_c = NULL, mu0_t = NULL, mu0_c = NULL, sigma0_t = NULL, sigma0_c = NULL, mu_t = 2.5, mu_c = 1.0, sigma_t = 1.3, sigma_c = 1.1, r = NULL, ne_t = 15, ne_c = 18, alpha0e_t = 0.6, alpha0e_c = 0.7, bar_ye_t = 2.3, bar_ye_c = 0.9, se_t = 1.2, se_c = 1.0, error_if_Miss = FALSE, Gray_inc_Miss = FALSE, seed = 6 )# Example 1: Controlled design with vague prior and NI method # (default: error_if_Miss = TRUE, Gray_inc_Miss = FALSE) pbayesdecisionprob1cont( nsim = 100, prob = 'posterior', design = 'controlled', prior = 'vague', CalcMethod = 'NI', theta_TV = 1.5, theta_MAV = -0.5, theta_NULL = NULL, nMC = NULL, gamma_go = 0.7, gamma_nogo = 0.2, n_t = 15, n_c = 15, m_t = NULL, m_c = NULL, kappa0_t = NULL, kappa0_c = NULL, nu0_t = NULL, nu0_c = NULL, mu0_t = NULL, mu0_c = NULL, sigma0_t = NULL, sigma0_c = NULL, mu_t = 3, mu_c = 1, sigma_t = 1.2, sigma_c = 1.1, 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, error_if_Miss = TRUE, Gray_inc_Miss = FALSE, seed = 2 ) # Example 2: Uncontrolled design with informative prior pbayesdecisionprob1cont( nsim = 100, prob = 'posterior', design = 'uncontrolled', prior = 'N-Inv-Chisq', CalcMethod = 'NI', theta_TV = 1.0, theta_MAV = 0.0, theta_NULL = NULL, nMC = NULL, gamma_go = 0.8, gamma_nogo = 0.2, n_t = 20, n_c = NULL, m_t = NULL, m_c = NULL, kappa0_t = 2, kappa0_c = NULL, nu0_t = 5, nu0_c = NULL, mu0_t = 3.0, mu0_c = 1.5, sigma0_t = 1.5, sigma0_c = NULL, mu_t = 3.5, mu_c = NULL, sigma_t = 1.3, sigma_c = NULL, r = 1, 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, error_if_Miss = TRUE, Gray_inc_Miss = FALSE, seed = 3 ) # Example 3: External design with control data using MM approximation pbayesdecisionprob1cont( nsim = 100, prob = 'posterior', design = 'external', prior = 'vague', CalcMethod = 'MM', theta_TV = 1.0, theta_MAV = 0.0, theta_NULL = NULL, nMC = NULL, gamma_go = 0.8, gamma_nogo = 0.2, n_t = 12, n_c = 12, m_t = NULL, m_c = NULL, kappa0_t = NULL, kappa0_c = NULL, nu0_t = NULL, nu0_c = NULL, mu0_t = NULL, mu0_c = NULL, sigma0_t = NULL, sigma0_c = NULL, mu_t = 2, mu_c = 0, sigma_t = 1, sigma_c = 1, r = NULL, ne_t = NULL, ne_c = 20, alpha0e_t = NULL, alpha0e_c = 0.5, bar_ye_t = NULL, bar_ye_c = 0, se_t = NULL, se_c = 1, error_if_Miss = TRUE, Gray_inc_Miss = FALSE, seed = 4 ) # Example 4: Controlled design with predictive probability pbayesdecisionprob1cont( nsim = 100, prob = 'predictive', design = 'controlled', prior = 'N-Inv-Chisq', CalcMethod = 'NI', theta_TV = NULL, theta_MAV = NULL, theta_NULL = 2.0, nMC = NULL, gamma_go = 0.75, gamma_nogo = 0.35, n_t = 15, n_c = 15, m_t = 50, m_c = 50, kappa0_t = 3, kappa0_c = 3, nu0_t = 4, nu0_c = 4, mu0_t = 3.5, mu0_c = 1.5, sigma0_t = 1.5, sigma0_c = 1.5, mu_t = 3.2, mu_c = 1.3, sigma_t = 1.4, sigma_c = 1.2, 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, error_if_Miss = TRUE, Gray_inc_Miss = FALSE, seed = 5 ) # Example 5: Uncontrolled design with predictive probability pbayesdecisionprob1cont( nsim = 100, prob = 'predictive', design = 'uncontrolled', prior = 'vague', CalcMethod = 'NI', theta_TV = NULL, theta_MAV = NULL, theta_NULL = 1.0, nMC = NULL, gamma_go = 0.75, gamma_nogo = 0.35, n_t = 20, n_c = NULL, m_t = 40, m_c = 40, kappa0_t = NULL, kappa0_c = NULL, nu0_t = NULL, nu0_c = NULL, mu0_t = NULL, mu0_c = 1.5, sigma0_t = NULL, sigma0_c = NULL, mu_t = 3, mu_c = NULL, sigma_t = 1.3, sigma_c = NULL, r = 1, 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, error_if_Miss = TRUE, Gray_inc_Miss = FALSE, seed = 9 ) # Example 6: External design with predictive probability using MC method pbayesdecisionprob1cont( nsim = 100, prob = 'predictive', design = 'external', prior = 'vague', CalcMethod = 'MC', theta_TV = NULL, theta_MAV = NULL, theta_NULL = 1.5, nMC = 5000, gamma_go = 0.7, gamma_nogo = 0.4, n_t = 12, n_c = 12, m_t = 30, m_c = 30, kappa0_t = NULL, kappa0_c = NULL, nu0_t = NULL, nu0_c = NULL, mu0_t = NULL, mu0_c = NULL, sigma0_t = NULL, sigma0_c = NULL, mu_t = 2.5, mu_c = 1.0, sigma_t = 1.3, sigma_c = 1.1, r = NULL, ne_t = 15, ne_c = 18, alpha0e_t = 0.6, alpha0e_c = 0.7, bar_ye_t = 2.3, bar_ye_c = 0.9, se_t = 1.2, se_c = 1.0, error_if_Miss = FALSE, Gray_inc_Miss = FALSE, seed = 6 )
Evaluates operating characteristics (Go, NoGo, Gray probabilities) for clinical trials with two binary endpoints under the Bayesian framework. The function supports controlled, uncontrolled, and external designs, and uses both posterior probability and posterior predictive probability criteria.
pbayesdecisionprob2bin( nsim = 10000L, prob = "posterior", design = "controlled", GoRegions, NoGoRegions, gamma_go, gamma_nogo, pi_t1, pi_t2, rho_t, pi_c1 = NULL, pi_c2 = NULL, rho_c = NULL, n_t, n_c = NULL, a_t_00, a_t_01, a_t_10, a_t_11, a_c_00, a_c_01, a_c_10, a_c_11, m_t = NULL, m_c = NULL, theta_TV1 = NULL, theta_MAV1 = NULL, theta_TV2 = NULL, theta_MAV2 = NULL, theta_NULL1 = NULL, theta_NULL2 = 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 = 10000L, CalcMethod = "Exact", error_if_Miss = TRUE, Gray_inc_Miss = FALSE )pbayesdecisionprob2bin( nsim = 10000L, prob = "posterior", design = "controlled", GoRegions, NoGoRegions, gamma_go, gamma_nogo, pi_t1, pi_t2, rho_t, pi_c1 = NULL, pi_c2 = NULL, rho_c = NULL, n_t, n_c = NULL, a_t_00, a_t_01, a_t_10, a_t_11, a_c_00, a_c_01, a_c_10, a_c_11, m_t = NULL, m_c = NULL, theta_TV1 = NULL, theta_MAV1 = NULL, theta_TV2 = NULL, theta_MAV2 = NULL, theta_NULL1 = NULL, theta_NULL2 = 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 = 10000L, CalcMethod = "Exact", error_if_Miss = TRUE, Gray_inc_Miss = FALSE )
nsim |
A positive integer giving the number of PoC count vectors
sampled via |
prob |
A character string specifying the probability type.
Must be |
design |
A character string specifying the trial design.
Must be |
GoRegions |
An integer vector specifying which of the nine posterior
regions (R1–R9) or four predictive regions (R1–R4) constitute a
Go decision. For |
NoGoRegions |
An integer vector specifying which regions constitute a
NoGo decision. A common choice is |
gamma_go |
A numeric scalar in |
gamma_nogo |
A numeric scalar in |
pi_t1 |
A numeric vector of true treatment response probabilities
for Endpoint 1. Each element must be in |
pi_t2 |
A numeric vector of true treatment response probabilities
for Endpoint 2. Must have the same length as |
rho_t |
A numeric vector of true within-treatment-arm correlations
between Endpoint 1 and Endpoint 2. Must have the same length as
|
pi_c1 |
A numeric vector of true control response probabilities for
Endpoint 1. For |
pi_c2 |
A numeric vector of true control response probabilities for
Endpoint 2. For |
rho_c |
A numeric vector of true within-control-arm correlations.
For |
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 |
a_t_00 |
A positive numeric scalar giving the Dirichlet prior
parameter for the |
a_t_01 |
A positive numeric scalar giving the Dirichlet prior
parameter for the |
a_t_10 |
A positive numeric scalar giving the Dirichlet prior
parameter for the |
a_t_11 |
A positive numeric scalar giving the Dirichlet prior
parameter for the |
a_c_00 |
A positive numeric scalar giving the Dirichlet prior
parameter for the |
a_c_01 |
A positive numeric scalar giving the Dirichlet prior
parameter for the |
a_c_10 |
A positive numeric scalar giving the Dirichlet prior
parameter for the |
a_c_11 |
A positive numeric scalar giving the Dirichlet prior
parameter for the |
m_t |
A positive integer giving the number of patients in the
treatment group for the future trial. Required when
|
m_c |
A positive integer giving the number of patients in the
control group for the future trial. Required when
|
theta_TV1 |
A numeric scalar giving the target value (TV) threshold
for Endpoint 1. Required when |
theta_MAV1 |
A numeric scalar giving the minimum acceptable value
(MAV) threshold for Endpoint 1. Required when
|
theta_TV2 |
A numeric scalar giving the target value (TV) threshold
for Endpoint 2. Required when |
theta_MAV2 |
A numeric scalar giving the minimum acceptable value
(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 |
z00 |
A non-negative integer giving the hypothetical control count
for pattern |
z01 |
A non-negative integer giving the hypothetical control count
for pattern |
z10 |
A non-negative integer giving the hypothetical control count
for pattern |
z11 |
A non-negative integer giving the hypothetical control count
for pattern |
xe_t_00 |
A non-negative integer giving the external treatment group
count for pattern |
xe_t_01 |
A non-negative integer giving the external treatment group
count for pattern |
xe_t_10 |
A non-negative integer giving the external treatment group
count for pattern |
xe_t_11 |
A non-negative integer giving the external treatment group
count for pattern |
xe_c_00 |
A non-negative integer giving the external control group
count for pattern |
xe_c_01 |
A non-negative integer giving the external control group
count for pattern |
xe_c_10 |
A non-negative integer giving the external control group
count for pattern |
xe_c_11 |
A non-negative integer giving the external control group
count for pattern |
alpha0e_t |
A numeric scalar in |
alpha0e_c |
A numeric scalar in |
nMC |
A positive integer giving the number of Dirichlet draws used to
evaluate the decision probability for each count combination in
Stage 1. Used by both |
CalcMethod |
A character string specifying the computation method.
Must be |
error_if_Miss |
A logical scalar; if |
Gray_inc_Miss |
A logical scalar; if |
Computation proceeds in two stages for efficiency. In Stage 1, posterior
or predictive probabilities are precomputed for every possible multinomial
count combination . In Stage 2, operating characteristics
for each scenario are obtained by weighting the Stage 1 decisions by their
multinomial probabilities under the true parameters, avoiding repeated Monte
Carlo sampling per scenario.
Two-stage computation.
Stage 1 (precomputation): All possible multinomial count combinations
are enumerated using allmultinom.
For design = 'controlled' or 'external', all combinations
are also enumerated and the Go/NoGo probability matrix
PrGo[i, j] has dimensions .
For design = 'uncontrolled', the control distribution is fixed as
and does not depend on any
observed control counts; the probability matrix therefore has dimensions
, eliminating the -row control
enumeration and the associated Gamma sampling.
This stage is independent of the true scenario parameters.
Stage 2 (scenario evaluation): For each scenario
,
getjointbin converts the marginal rates and correlation
into the four-cell probability vector . The multinomial
probability mass function weights the Stage 1 decisions:
where is the Go indicator from Stage 1.
Stage 2 requires no additional Monte Carlo and is fast even for large
scenario grids.
Decision categories.
Go: sum of Go region probabilities
AND sum of NoGo region probabilities .
NoGo: sum of Go region probabilities
AND sum of NoGo region probabilities .
Miss: both Go and NoGo criteria satisfied simultaneously.
Gray: neither Go nor NoGo criterion satisfied.
A data frame with one row per scenario and columns:
True treatment response probability for Endpoint 1.
True treatment response probability for Endpoint 2.
True within-arm correlation in the treatment arm.
True control response probability for Endpoint 1
(omitted when design = 'uncontrolled').
True control response probability for Endpoint 2
(omitted when design = 'uncontrolled').
True within-arm correlation in the control arm
(omitted when design = 'uncontrolled').
Probability of making a Go decision.
Probability of making a Gray (inconclusive) decision.
Probability of making a NoGo decision.
Probability where Go and NoGo criteria are simultaneously
met. Included when error_if_Miss = FALSE and
Gray_inc_Miss = FALSE.
The returned object has S3 class pbayesdecisionprob2bin with
an associated print method.
# Example 1: Posterior probability, controlled design (rho > 0) # Explores the impact of positive within-arm endpoint correlation. pbayesdecisionprob2bin( prob = 'posterior', design = 'controlled', GoRegions = 1L, NoGoRegions = 9L, gamma_go = 0.52, gamma_nogo = 0.52, pi_t1 = c(0.15, 0.25, 0.30, 0.40), pi_t2 = c(0.20, 0.30, 0.35, 0.45), rho_t = rep(0.6, 4), pi_c1 = rep(0.15, 4), pi_c2 = rep(0.20, 4), rho_c = rep(0.6, 4), n_t = 10, n_c = 10, 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, m_t = NULL, m_c = NULL, theta_TV1 = 0.15, theta_MAV1 = 0.10, theta_TV2 = 0.15, theta_MAV2 = 0.10, theta_NULL1 = NULL, theta_NULL2 = 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 = 100, error_if_Miss = FALSE, Gray_inc_Miss = FALSE ) # Example 2: Posterior probability, uncontrolled design # Hypothetical control specified via pseudo-counts. pbayesdecisionprob2bin( prob = 'posterior', design = 'uncontrolled', GoRegions = 1L, NoGoRegions = 9L, gamma_go = 0.27, gamma_nogo = 0.36, pi_t1 = c(0.15, 0.30, 0.40), pi_t2 = c(0.20, 0.35, 0.45), rho_t = rep(0.2, 3), pi_c1 = NULL, pi_c2 = NULL, rho_c = NULL, n_t = 10, n_c = NULL, 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, m_t = NULL, m_c = NULL, theta_TV1 = 0.15, theta_MAV1 = 0.10, theta_TV2 = 0.15, theta_MAV2 = 0.10, theta_NULL1 = NULL, theta_NULL2 = NULL, z00 = 2L, z01 = 1L, z10 = 2L, z11 = 1L, 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 = 100, error_if_Miss = FALSE, Gray_inc_Miss = FALSE ) # Example 3: Posterior probability, external control design # External control data incorporated via power prior (alpha0e_c = 0.5). pbayesdecisionprob2bin( prob = 'posterior', design = 'external', GoRegions = 1L, NoGoRegions = 9L, gamma_go = 0.27, gamma_nogo = 0.36, pi_t1 = c(0.15, 0.25, 0.30, 0.40), pi_t2 = c(0.20, 0.30, 0.35, 0.45), rho_t = rep(0.0, 4), pi_c1 = rep(0.15, 4), pi_c2 = rep(0.20, 4), rho_c = rep(0.0, 4), n_t = 10, n_c = 10, 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, m_t = NULL, m_c = NULL, theta_TV1 = 0.15, theta_MAV1 = 0.10, theta_TV2 = 0.15, theta_MAV2 = 0.10, theta_NULL1 = NULL, theta_NULL2 = 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 = 4L, xe_c_01 = 2L, xe_c_10 = 3L, xe_c_11 = 1L, alpha0e_t = NULL, alpha0e_c = 0.5, nMC = 100, error_if_Miss = FALSE, Gray_inc_Miss = FALSE ) # Example 4: Predictive probability, controlled design # Future trial has m_t = m_c = 30 patients per arm. pbayesdecisionprob2bin( prob = 'predictive', design = 'controlled', GoRegions = 1L, NoGoRegions = 4L, gamma_go = 0.60, gamma_nogo = 0.80, pi_t1 = c(0.15, 0.25, 0.30, 0.40), pi_t2 = c(0.20, 0.30, 0.35, 0.45), rho_t = rep(0.3, 4), pi_c1 = rep(0.15, 4), pi_c2 = rep(0.20, 4), rho_c = rep(0.3, 4), n_t = 10, n_c = 10, 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, m_t = 30L, m_c = 30L, theta_TV1 = NULL, theta_MAV1 = NULL, theta_TV2 = NULL, theta_MAV2 = NULL, theta_NULL1 = 0.10, theta_NULL2 = 0.10, 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 = 100, error_if_Miss = FALSE, Gray_inc_Miss = FALSE ) # Example 5: Predictive probability, uncontrolled design # Hypothetical control specified via pseudo-counts; future trial m_t = m_c = 30. pbayesdecisionprob2bin( prob = 'predictive', design = 'uncontrolled', GoRegions = 1L, NoGoRegions = 4L, gamma_go = 0.60, gamma_nogo = 0.80, pi_t1 = c(0.15, 0.30, 0.40), pi_t2 = c(0.20, 0.35, 0.45), rho_t = rep(0.7, 3), pi_c1 = rep(0.15, 3), pi_c2 = rep(0.20, 3), rho_c = rep(0.7, 3), n_t = 10, n_c = 10, 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, m_t = 30L, m_c = 30L, theta_TV1 = NULL, theta_MAV1 = NULL, theta_TV2 = NULL, theta_MAV2 = NULL, theta_NULL1 = 0.10, theta_NULL2 = 0.10, z00 = 2L, z01 = 1L, z10 = 2L, z11 = 1L, 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 = 100, error_if_Miss = FALSE, Gray_inc_Miss = FALSE ) # Example 6: Predictive probability, external treatment design # External treatment data incorporated via power prior (alpha0e_t = 0.5). pbayesdecisionprob2bin( prob = 'predictive', design = 'external', GoRegions = 1L, NoGoRegions = 4L, gamma_go = 0.60, gamma_nogo = 0.80, pi_t1 = c(0.15, 0.25, 0.30, 0.40), pi_t2 = c(0.20, 0.30, 0.35, 0.45), rho_t = rep(0.5, 4), pi_c1 = rep(0.15, 4), pi_c2 = rep(0.20, 4), rho_c = rep(0.5, 4), n_t = 10, n_c = 10, 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, m_t = 30L, m_c = 30L, theta_TV1 = NULL, theta_MAV1 = NULL, theta_TV2 = NULL, theta_MAV2 = NULL, theta_NULL1 = 0.10, theta_NULL2 = 0.10, 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 = 100, error_if_Miss = FALSE, Gray_inc_Miss = FALSE )# Example 1: Posterior probability, controlled design (rho > 0) # Explores the impact of positive within-arm endpoint correlation. pbayesdecisionprob2bin( prob = 'posterior', design = 'controlled', GoRegions = 1L, NoGoRegions = 9L, gamma_go = 0.52, gamma_nogo = 0.52, pi_t1 = c(0.15, 0.25, 0.30, 0.40), pi_t2 = c(0.20, 0.30, 0.35, 0.45), rho_t = rep(0.6, 4), pi_c1 = rep(0.15, 4), pi_c2 = rep(0.20, 4), rho_c = rep(0.6, 4), n_t = 10, n_c = 10, 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, m_t = NULL, m_c = NULL, theta_TV1 = 0.15, theta_MAV1 = 0.10, theta_TV2 = 0.15, theta_MAV2 = 0.10, theta_NULL1 = NULL, theta_NULL2 = 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 = 100, error_if_Miss = FALSE, Gray_inc_Miss = FALSE ) # Example 2: Posterior probability, uncontrolled design # Hypothetical control specified via pseudo-counts. pbayesdecisionprob2bin( prob = 'posterior', design = 'uncontrolled', GoRegions = 1L, NoGoRegions = 9L, gamma_go = 0.27, gamma_nogo = 0.36, pi_t1 = c(0.15, 0.30, 0.40), pi_t2 = c(0.20, 0.35, 0.45), rho_t = rep(0.2, 3), pi_c1 = NULL, pi_c2 = NULL, rho_c = NULL, n_t = 10, n_c = NULL, 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, m_t = NULL, m_c = NULL, theta_TV1 = 0.15, theta_MAV1 = 0.10, theta_TV2 = 0.15, theta_MAV2 = 0.10, theta_NULL1 = NULL, theta_NULL2 = NULL, z00 = 2L, z01 = 1L, z10 = 2L, z11 = 1L, 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 = 100, error_if_Miss = FALSE, Gray_inc_Miss = FALSE ) # Example 3: Posterior probability, external control design # External control data incorporated via power prior (alpha0e_c = 0.5). pbayesdecisionprob2bin( prob = 'posterior', design = 'external', GoRegions = 1L, NoGoRegions = 9L, gamma_go = 0.27, gamma_nogo = 0.36, pi_t1 = c(0.15, 0.25, 0.30, 0.40), pi_t2 = c(0.20, 0.30, 0.35, 0.45), rho_t = rep(0.0, 4), pi_c1 = rep(0.15, 4), pi_c2 = rep(0.20, 4), rho_c = rep(0.0, 4), n_t = 10, n_c = 10, 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, m_t = NULL, m_c = NULL, theta_TV1 = 0.15, theta_MAV1 = 0.10, theta_TV2 = 0.15, theta_MAV2 = 0.10, theta_NULL1 = NULL, theta_NULL2 = 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 = 4L, xe_c_01 = 2L, xe_c_10 = 3L, xe_c_11 = 1L, alpha0e_t = NULL, alpha0e_c = 0.5, nMC = 100, error_if_Miss = FALSE, Gray_inc_Miss = FALSE ) # Example 4: Predictive probability, controlled design # Future trial has m_t = m_c = 30 patients per arm. pbayesdecisionprob2bin( prob = 'predictive', design = 'controlled', GoRegions = 1L, NoGoRegions = 4L, gamma_go = 0.60, gamma_nogo = 0.80, pi_t1 = c(0.15, 0.25, 0.30, 0.40), pi_t2 = c(0.20, 0.30, 0.35, 0.45), rho_t = rep(0.3, 4), pi_c1 = rep(0.15, 4), pi_c2 = rep(0.20, 4), rho_c = rep(0.3, 4), n_t = 10, n_c = 10, 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, m_t = 30L, m_c = 30L, theta_TV1 = NULL, theta_MAV1 = NULL, theta_TV2 = NULL, theta_MAV2 = NULL, theta_NULL1 = 0.10, theta_NULL2 = 0.10, 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 = 100, error_if_Miss = FALSE, Gray_inc_Miss = FALSE ) # Example 5: Predictive probability, uncontrolled design # Hypothetical control specified via pseudo-counts; future trial m_t = m_c = 30. pbayesdecisionprob2bin( prob = 'predictive', design = 'uncontrolled', GoRegions = 1L, NoGoRegions = 4L, gamma_go = 0.60, gamma_nogo = 0.80, pi_t1 = c(0.15, 0.30, 0.40), pi_t2 = c(0.20, 0.35, 0.45), rho_t = rep(0.7, 3), pi_c1 = rep(0.15, 3), pi_c2 = rep(0.20, 3), rho_c = rep(0.7, 3), n_t = 10, n_c = 10, 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, m_t = 30L, m_c = 30L, theta_TV1 = NULL, theta_MAV1 = NULL, theta_TV2 = NULL, theta_MAV2 = NULL, theta_NULL1 = 0.10, theta_NULL2 = 0.10, z00 = 2L, z01 = 1L, z10 = 2L, z11 = 1L, 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 = 100, error_if_Miss = FALSE, Gray_inc_Miss = FALSE ) # Example 6: Predictive probability, external treatment design # External treatment data incorporated via power prior (alpha0e_t = 0.5). pbayesdecisionprob2bin( prob = 'predictive', design = 'external', GoRegions = 1L, NoGoRegions = 4L, gamma_go = 0.60, gamma_nogo = 0.80, pi_t1 = c(0.15, 0.25, 0.30, 0.40), pi_t2 = c(0.20, 0.30, 0.35, 0.45), rho_t = rep(0.5, 4), pi_c1 = rep(0.15, 4), pi_c2 = rep(0.20, 4), rho_c = rep(0.5, 4), n_t = 10, n_c = 10, 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, m_t = 30L, m_c = 30L, theta_TV1 = NULL, theta_MAV1 = NULL, theta_TV2 = NULL, theta_MAV2 = NULL, theta_NULL1 = 0.10, theta_NULL2 = 0.10, 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 = 100, error_if_Miss = FALSE, Gray_inc_Miss = FALSE )
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.
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 )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 )
nsim |
A positive integer. Number of simulated datasets per scenario. |
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 specifying which of the nine posterior
regions (R1–R9) or four predictive regions (R1–R4) constitute a
Go decision. For |
NoGoRegions |
An integer vector specifying which regions constitute a
NoGo decision. A common choice is |
gamma_go |
A numeric scalar in |
gamma_nogo |
A numeric scalar in |
theta_TV1 |
A numeric scalar giving the target value (TV) threshold
for Endpoint 1. Required when |
theta_MAV1 |
A numeric scalar giving the minimum acceptable value
(MAV) threshold for Endpoint 1. Required when
|
theta_TV2 |
A numeric scalar giving the target value (TV) threshold
for Endpoint 2. Required when |
theta_MAV2 |
A numeric scalar giving the minimum acceptable value
(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 |
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 |
m_t |
A positive integer giving the number of patients in the
treatment group for the future trial. Required when
|
m_c |
A positive integer giving the number of patients in the
control group for the future trial. Required when
|
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
|
nu0_t |
A numeric scalar giving the NIW prior degrees of freedom for
the treatment group. Must be greater than 3. Required when
|
mu0_t |
A numeric vector of length 2 giving the NIW prior mean for
the treatment group. Required when
|
Lambda0_t |
A 2x2 positive-definite numeric matrix giving the NIW
prior scale matrix for the treatment group. Required when
|
kappa0_c |
A positive numeric scalar giving the NIW prior
concentration parameter for the control group. Required when
|
nu0_c |
A numeric scalar giving the NIW prior degrees of freedom for
the control group. Must be greater than 3. Required when
|
mu0_c |
A numeric vector of length 2 giving the NIW prior mean for
the control group, or the hypothetical control location when
|
Lambda0_c |
A 2x2 positive-definite numeric matrix giving the NIW
prior scale matrix for the control group. Required when
|
r |
A positive numeric scalar giving the variance scaling factor for
the hypothetical control distribution. Required when
|
ne_t |
A positive integer giving the external treatment group sample
size. Required when |
ne_c |
A positive integer giving the external control group sample
size. Required when |
alpha0e_t |
A numeric scalar in |
alpha0e_c |
A numeric scalar in |
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 |
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 |
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 |
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 |
nMC |
A positive integer giving the number of Monte Carlo draws used
to estimate region probabilities. Default is |
CalcMethod |
A character string specifying the computation method.
Must be |
error_if_Miss |
Logical. If |
Gray_inc_Miss |
Logical. If |
seed |
A single numeric value. Seed for reproducible random number generation. |
The function follows the same structure as
pbayesdecisionprob1cont:
For each scenario , nsim datasets are simulated by
generating treatment (and control) observations from
. To minimise overhead, raw
standardised residuals are generated once (scenario-
invariant) and shifted by the scenario mean.
All nsim simulated sufficient statistics
(and
for controlled/external designs) are passed to
pbayespostpred2cont in a single vectorised
call, returning an matrix of
region probabilities.
Go/NoGo/Miss probabilities are obtained as the column means of indicator matrices derived from the region probability matrix.
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.
# 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 )# 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 )
Computes the Bayesian posterior probability or posterior predictive
probability for binary-outcome clinical trials under a beta-binomial
conjugate model. The function supports controlled, uncontrolled, and
external designs, with optional incorporation of external data through
power priors. Vector inputs for y_t and y_c are supported
for efficient batch processing (e.g., across all possible trial outcomes
in pbayesdecisionprob1bin).
pbayespostpred1bin( prob = "posterior", design = "controlled", theta0, n_t, n_c, y_t, y_c = NULL, a_t, a_c, b_t, b_c, m_t = NULL, m_c = NULL, z = NULL, ne_t = NULL, ne_c = NULL, ye_t = NULL, ye_c = NULL, alpha0e_t = NULL, alpha0e_c = NULL, lower.tail = TRUE )pbayespostpred1bin( prob = "posterior", design = "controlled", theta0, n_t, n_c, y_t, y_c = NULL, a_t, a_c, b_t, b_c, m_t = NULL, m_c = NULL, z = NULL, ne_t = NULL, ne_c = NULL, ye_t = NULL, ye_c = NULL, alpha0e_t = NULL, alpha0e_c = NULL, lower.tail = TRUE )
prob |
A character string specifying the probability type.
Must be |
design |
A character string specifying the trial design.
Must be |
theta0 |
A numeric scalar in |
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 |
y_t |
A non-negative integer or integer vector giving the observed
number of responders in the treatment group (must satisfy
|
y_c |
A non-negative integer or integer vector giving the number of
responders in the control group (must satisfy
|
a_t |
A positive numeric scalar giving the first shape parameter (alpha) of the prior Beta distribution for the treatment group. |
a_c |
A positive numeric scalar giving the first shape parameter (alpha) of the prior Beta distribution for the control group. |
b_t |
A positive numeric scalar giving the second shape parameter (beta) of the prior Beta distribution for the treatment group. |
b_c |
A positive numeric scalar giving the second shape parameter (beta) of the prior Beta distribution for the control group. |
m_t |
A positive integer giving the number of patients in the
treatment group for the future trial. Required when
|
m_c |
A positive integer giving the number of patients in the
control group for the future trial. Required when
|
z |
A non-negative integer giving the hypothetical number of responders
in the control group. Required when |
ne_t |
A positive integer giving the number of patients in the
treatment group of the external data set. Required when
|
ne_c |
A positive integer giving the number of patients in the
control group of the external data set. Required when
|
ye_t |
A non-negative integer giving the number of responders in the
treatment group of the external data set. Required when
|
ye_c |
A non-negative integer giving the number of responders in the
control group of the external data set. Required when
|
alpha0e_t |
A numeric scalar in |
alpha0e_c |
A numeric scalar in |
lower.tail |
A logical scalar; if |
Posterior shape parameters are computed from the beta-binomial conjugate model:
Prior: .
Posterior:
.
For design = 'external', external data are incorporated through
the power prior, which inflates the prior by the weighted external
sufficient statistics:
For design = 'uncontrolled', the hypothetical control value
z is used in place of y_c, and n_c acts as the
hypothetical control sample size.
The final probability is obtained by calling pbetadiff for
prob = 'posterior' or pbetabinomdiff for
prob = 'predictive', applied element-wise via mapply.
A numeric scalar or vector in [0, 1]. When y_t and
y_c are vectors of length , a vector of length
is returned.
# Example 1: Controlled design - posterior probability pbayespostpred1bin( prob = 'posterior', design = 'controlled', theta0 = 0.15, n_t = 12, n_c = 15, y_t = 7, y_c = 5, a_t = 0.5, a_c = 0.5, b_t = 0.5, b_c = 0.5, m_t = NULL, m_c = NULL, z = NULL, ne_t = NULL, ne_c = NULL, ye_t = NULL, ye_c = NULL, alpha0e_t = NULL, alpha0e_c = NULL, lower.tail = FALSE ) # Example 2: Uncontrolled design - posterior probability pbayespostpred1bin( prob = 'posterior', design = 'uncontrolled', theta0 = 0.20, n_t = 20, n_c = 20, y_t = 12, y_c = NULL, a_t = 0.5, a_c = 0.5, b_t = 0.5, b_c = 0.5, m_t = NULL, m_c = NULL, z = 3, ne_t = NULL, ne_c = NULL, ye_t = NULL, ye_c = NULL, alpha0e_t = NULL, alpha0e_c = NULL, lower.tail = FALSE ) # Example 3: External design - posterior probability pbayespostpred1bin( prob = 'posterior', design = 'external', theta0 = 0.15, n_t = 12, n_c = 15, y_t = 7, y_c = 9, a_t = 0.5, a_c = 0.5, b_t = 0.5, b_c = 0.5, m_t = NULL, m_c = NULL, z = NULL, ne_t = 12, ne_c = 12, ye_t = 6, ye_c = 6, alpha0e_t = 0.5, alpha0e_c = 0.5, lower.tail = FALSE ) # Example 4: Controlled design - posterior predictive probability pbayespostpred1bin( prob = 'predictive', design = 'controlled', theta0 = 0.10, n_t = 12, n_c = 15, y_t = 7, y_c = 5, a_t = 0.5, a_c = 0.5, b_t = 0.5, b_c = 0.5, m_t = 30, m_c = 30, z = NULL, ne_t = NULL, ne_c = NULL, ye_t = NULL, ye_c = NULL, alpha0e_t = NULL, alpha0e_c = NULL, lower.tail = FALSE ) # Example 5: Uncontrolled design - posterior predictive probability pbayespostpred1bin( prob = 'predictive', design = 'uncontrolled', theta0 = 0.20, n_t = 20, n_c = 20, y_t = 12, y_c = NULL, a_t = 0.5, a_c = 0.5, b_t = 0.5, b_c = 0.5, m_t = 30, m_c = 30, z = 3, ne_t = NULL, ne_c = NULL, ye_t = NULL, ye_c = NULL, alpha0e_t = NULL, alpha0e_c = NULL, lower.tail = FALSE ) # Example 6: External design - posterior predictive probability pbayespostpred1bin( prob = 'predictive', design = 'external', theta0 = 0.15, n_t = 12, n_c = 15, y_t = 7, y_c = 9, a_t = 0.5, a_c = 0.5, b_t = 0.5, b_c = 0.5, m_t = 30, m_c = 30, z = NULL, ne_t = 12, ne_c = 12, ye_t = 6, ye_c = 6, alpha0e_t = 0.5, alpha0e_c = 0.5, lower.tail = FALSE )# Example 1: Controlled design - posterior probability pbayespostpred1bin( prob = 'posterior', design = 'controlled', theta0 = 0.15, n_t = 12, n_c = 15, y_t = 7, y_c = 5, a_t = 0.5, a_c = 0.5, b_t = 0.5, b_c = 0.5, m_t = NULL, m_c = NULL, z = NULL, ne_t = NULL, ne_c = NULL, ye_t = NULL, ye_c = NULL, alpha0e_t = NULL, alpha0e_c = NULL, lower.tail = FALSE ) # Example 2: Uncontrolled design - posterior probability pbayespostpred1bin( prob = 'posterior', design = 'uncontrolled', theta0 = 0.20, n_t = 20, n_c = 20, y_t = 12, y_c = NULL, a_t = 0.5, a_c = 0.5, b_t = 0.5, b_c = 0.5, m_t = NULL, m_c = NULL, z = 3, ne_t = NULL, ne_c = NULL, ye_t = NULL, ye_c = NULL, alpha0e_t = NULL, alpha0e_c = NULL, lower.tail = FALSE ) # Example 3: External design - posterior probability pbayespostpred1bin( prob = 'posterior', design = 'external', theta0 = 0.15, n_t = 12, n_c = 15, y_t = 7, y_c = 9, a_t = 0.5, a_c = 0.5, b_t = 0.5, b_c = 0.5, m_t = NULL, m_c = NULL, z = NULL, ne_t = 12, ne_c = 12, ye_t = 6, ye_c = 6, alpha0e_t = 0.5, alpha0e_c = 0.5, lower.tail = FALSE ) # Example 4: Controlled design - posterior predictive probability pbayespostpred1bin( prob = 'predictive', design = 'controlled', theta0 = 0.10, n_t = 12, n_c = 15, y_t = 7, y_c = 5, a_t = 0.5, a_c = 0.5, b_t = 0.5, b_c = 0.5, m_t = 30, m_c = 30, z = NULL, ne_t = NULL, ne_c = NULL, ye_t = NULL, ye_c = NULL, alpha0e_t = NULL, alpha0e_c = NULL, lower.tail = FALSE ) # Example 5: Uncontrolled design - posterior predictive probability pbayespostpred1bin( prob = 'predictive', design = 'uncontrolled', theta0 = 0.20, n_t = 20, n_c = 20, y_t = 12, y_c = NULL, a_t = 0.5, a_c = 0.5, b_t = 0.5, b_c = 0.5, m_t = 30, m_c = 30, z = 3, ne_t = NULL, ne_c = NULL, ye_t = NULL, ye_c = NULL, alpha0e_t = NULL, alpha0e_c = NULL, lower.tail = FALSE ) # Example 6: External design - posterior predictive probability pbayespostpred1bin( prob = 'predictive', design = 'external', theta0 = 0.15, n_t = 12, n_c = 15, y_t = 7, y_c = 9, a_t = 0.5, a_c = 0.5, b_t = 0.5, b_c = 0.5, m_t = 30, m_c = 30, z = NULL, ne_t = 12, ne_c = 12, ye_t = 6, ye_c = 6, alpha0e_t = 0.5, alpha0e_c = 0.5, lower.tail = FALSE )
Computes the Bayesian posterior probability or posterior predictive
probability for continuous-outcome clinical trials under a
Normal-Inverse-Chi-squared (or vague Jeffreys) conjugate model. The
function supports controlled, uncontrolled, and external designs, with
optional incorporation of external data through power priors. Vector
inputs for bar_y_t, s_t, bar_y_c, and s_c
are supported for efficient batch processing (e.g., across simulation
replicates in pbayesdecisionprob1cont).
pbayespostpred1cont( prob = "posterior", design = "controlled", prior = "vague", CalcMethod = "NI", theta0, nMC = NULL, n_t, n_c = NULL, m_t = NULL, m_c = NULL, kappa0_t = NULL, kappa0_c = NULL, nu0_t = NULL, nu0_c = NULL, mu0_t = NULL, mu0_c = NULL, sigma0_t = NULL, sigma0_c = NULL, bar_y_t, bar_y_c = NULL, s_t, s_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, lower.tail = TRUE )pbayespostpred1cont( prob = "posterior", design = "controlled", prior = "vague", CalcMethod = "NI", theta0, nMC = NULL, n_t, n_c = NULL, m_t = NULL, m_c = NULL, kappa0_t = NULL, kappa0_c = NULL, nu0_t = NULL, nu0_c = NULL, mu0_t = NULL, mu0_c = NULL, sigma0_t = NULL, sigma0_c = NULL, bar_y_t, bar_y_c = NULL, s_t, s_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, lower.tail = TRUE )
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 type.
Must be |
CalcMethod |
A character string specifying the calculation method.
Must be |
theta0 |
A numeric scalar giving the threshold for the treatment effect (difference in means). |
nMC |
A positive integer giving the number of Monte Carlo draws.
Required when |
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. Required for
|
m_t |
A positive integer giving the number of patients in the
treatment group for the future trial. Required when
|
m_c |
A positive integer giving the number of patients in the
control group for the future trial. Required when
|
kappa0_t |
A positive numeric scalar giving the prior precision
parameter for the treatment group. Required when
|
kappa0_c |
A positive numeric scalar giving the prior precision
parameter for the control group. Required when
|
nu0_t |
A positive numeric scalar giving the prior degrees of freedom
for the treatment group. Required when |
nu0_c |
A positive numeric scalar giving the prior degrees of freedom
for the control group. Required when |
mu0_t |
A numeric scalar giving the prior mean for the treatment
group. Required when |
mu0_c |
A numeric scalar giving the prior mean for the control group
( |
sigma0_t |
A positive numeric scalar giving the prior scale for the
treatment group. Required when |
sigma0_c |
A positive numeric scalar giving the prior scale for the
control group. Required when |
bar_y_t |
A numeric scalar or vector giving the sample mean for the
treatment group. When a vector of length |
bar_y_c |
A numeric scalar or vector giving the sample mean for the
control group. Required for |
s_t |
A positive numeric scalar or vector giving the sample standard deviation for the treatment group. |
s_c |
A positive numeric scalar or vector giving the sample standard
deviation for the control group. Required for
|
r |
A positive numeric scalar giving the variance scaling factor for
the hypothetical control. Required for |
ne_t |
A positive integer giving the number of patients in the
treatment group of the external data set. Required when
|
ne_c |
A positive integer giving the number of patients in the
control group of the external data set. Required when
|
alpha0e_t |
A numeric scalar in |
alpha0e_c |
A numeric scalar in |
bar_ye_t |
A numeric scalar giving the external treatment group
sample mean. Required when |
bar_ye_c |
A numeric scalar giving the external control group sample
mean. Required when |
se_t |
A positive numeric scalar giving the external treatment group
sample SD. Required when |
se_c |
A positive numeric scalar giving the external control group
sample SD. Required when |
lower.tail |
A logical scalar; if |
Under the Normal-Inverse-Chi-squared (N-Inv-ChiSq) conjugate model, the
marginal posterior/predictive distribution of the group mean follows a
non-standardised t-distribution, parameterised by a location
, a scale , and degrees of freedom
that depend on the design and probability type. The final probability is
computed by one of three methods:
NI: exact numerical integration via ptdiff_NI.
MC: Monte Carlo simulation via ptdiff_MC.
MM: Moment-Matching approximation via
ptdiff_MM.
Performance note: CalcMethod = 'NI' calls
integrate() once per element of the input vector, which is
prohibitively slow for large vectors (e.g., nsim x n_scenarios).
CalcMethod = 'MC' creates an nMC x n matrix internally,
consuming memory. For large-scale simulation use
CalcMethod = 'MM', which is fully vectorised and exact in the
normal limit.
A numeric scalar or vector in [0, 1]. When the input data
parameters (bar_y_t, etc.) are vectors of length ,
a vector of length is returned.
# Example 1: Controlled design - posterior probability with N-Inv-Chisq pbayespostpred1cont( prob = 'posterior', design = 'controlled', prior = 'N-Inv-Chisq', CalcMethod = 'NI', theta0 = 2, n_t = 12, n_c = 12, kappa0_t = 5, kappa0_c = 5, nu0_t = 5, nu0_c = 5, mu0_t = 5, mu0_c = 5, sigma0_t = sqrt(5), sigma0_c = sqrt(5), bar_y_t = 2, bar_y_c = 0, s_t = 1, s_c = 1, m_t = NULL, m_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, lower.tail = FALSE ) # Example 2: Uncontrolled design - posterior probability with vague prior pbayespostpred1cont( prob = 'posterior', design = 'uncontrolled', prior = 'vague', CalcMethod = 'MM', theta0 = 1.5, n_t = 15, n_c = NULL, bar_y_t = 3.5, bar_y_c = NULL, s_t = 1.2, s_c = NULL, mu0_c = 1.5, r = 1.2, kappa0_t = NULL, kappa0_c = NULL, nu0_t = NULL, nu0_c = NULL, mu0_t = NULL, sigma0_t = NULL, sigma0_c = NULL, m_t = NULL, m_c = 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, lower.tail = FALSE ) # Example 3: External design - posterior probability pbayespostpred1cont( prob = 'posterior', design = 'external', prior = 'N-Inv-Chisq', CalcMethod = 'MM', theta0 = 2, n_t = 12, n_c = 12, kappa0_t = 5, kappa0_c = 5, nu0_t = 5, nu0_c = 5, mu0_t = 5, mu0_c = 5, sigma0_t = sqrt(5), sigma0_c = sqrt(5), bar_y_t = 2.5, bar_y_c = 1, s_t = 1.1, s_c = 0.9, m_t = NULL, m_c = NULL, r = NULL, ne_t = 10, ne_c = 10, alpha0e_t = 0.5, alpha0e_c = 0.5, bar_ye_t = 2, bar_ye_c = 0.5, se_t = 1, se_c = 0.8, lower.tail = FALSE ) # Example 4: Controlled design - posterior predictive probability pbayespostpred1cont( prob = 'predictive', design = 'controlled', prior = 'N-Inv-Chisq', CalcMethod = 'MM', theta0 = 1, n_t = 12, n_c = 12, kappa0_t = 5, kappa0_c = 5, nu0_t = 5, nu0_c = 5, mu0_t = 5, mu0_c = 5, sigma0_t = sqrt(5), sigma0_c = sqrt(5), bar_y_t = 2, bar_y_c = 0, s_t = 1, s_c = 1, m_t = 20, m_c = 20, 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, lower.tail = FALSE ) # Example 5: Uncontrolled design - posterior predictive probability pbayespostpred1cont( prob = 'predictive', design = 'uncontrolled', prior = 'vague', CalcMethod = 'MM', theta0 = 1.5, n_t = 15, n_c = NULL, bar_y_t = 3.5, bar_y_c = NULL, s_t = 1.2, s_c = NULL, mu0_c = 1.5, r = 1.2, kappa0_t = NULL, kappa0_c = NULL, nu0_t = NULL, nu0_c = NULL, mu0_t = NULL, sigma0_t = NULL, sigma0_c = NULL, m_t = 20, m_c = 20, 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, lower.tail = FALSE ) # Example 6: External design - posterior predictive probability pbayespostpred1cont( prob = 'predictive', design = 'external', prior = 'N-Inv-Chisq', CalcMethod = 'MM', theta0 = 1, n_t = 12, n_c = 12, kappa0_t = 5, kappa0_c = 5, nu0_t = 5, nu0_c = 5, mu0_t = 5, mu0_c = 5, sigma0_t = sqrt(5), sigma0_c = sqrt(5), bar_y_t = 2.5, bar_y_c = 1, s_t = 1.1, s_c = 0.9, m_t = 20, m_c = 20, r = NULL, ne_t = 10, ne_c = 10, alpha0e_t = 0.5, alpha0e_c = 0.5, bar_ye_t = 2, bar_ye_c = 0.5, se_t = 1, se_c = 0.8, lower.tail = FALSE )# Example 1: Controlled design - posterior probability with N-Inv-Chisq pbayespostpred1cont( prob = 'posterior', design = 'controlled', prior = 'N-Inv-Chisq', CalcMethod = 'NI', theta0 = 2, n_t = 12, n_c = 12, kappa0_t = 5, kappa0_c = 5, nu0_t = 5, nu0_c = 5, mu0_t = 5, mu0_c = 5, sigma0_t = sqrt(5), sigma0_c = sqrt(5), bar_y_t = 2, bar_y_c = 0, s_t = 1, s_c = 1, m_t = NULL, m_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, lower.tail = FALSE ) # Example 2: Uncontrolled design - posterior probability with vague prior pbayespostpred1cont( prob = 'posterior', design = 'uncontrolled', prior = 'vague', CalcMethod = 'MM', theta0 = 1.5, n_t = 15, n_c = NULL, bar_y_t = 3.5, bar_y_c = NULL, s_t = 1.2, s_c = NULL, mu0_c = 1.5, r = 1.2, kappa0_t = NULL, kappa0_c = NULL, nu0_t = NULL, nu0_c = NULL, mu0_t = NULL, sigma0_t = NULL, sigma0_c = NULL, m_t = NULL, m_c = 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, lower.tail = FALSE ) # Example 3: External design - posterior probability pbayespostpred1cont( prob = 'posterior', design = 'external', prior = 'N-Inv-Chisq', CalcMethod = 'MM', theta0 = 2, n_t = 12, n_c = 12, kappa0_t = 5, kappa0_c = 5, nu0_t = 5, nu0_c = 5, mu0_t = 5, mu0_c = 5, sigma0_t = sqrt(5), sigma0_c = sqrt(5), bar_y_t = 2.5, bar_y_c = 1, s_t = 1.1, s_c = 0.9, m_t = NULL, m_c = NULL, r = NULL, ne_t = 10, ne_c = 10, alpha0e_t = 0.5, alpha0e_c = 0.5, bar_ye_t = 2, bar_ye_c = 0.5, se_t = 1, se_c = 0.8, lower.tail = FALSE ) # Example 4: Controlled design - posterior predictive probability pbayespostpred1cont( prob = 'predictive', design = 'controlled', prior = 'N-Inv-Chisq', CalcMethod = 'MM', theta0 = 1, n_t = 12, n_c = 12, kappa0_t = 5, kappa0_c = 5, nu0_t = 5, nu0_c = 5, mu0_t = 5, mu0_c = 5, sigma0_t = sqrt(5), sigma0_c = sqrt(5), bar_y_t = 2, bar_y_c = 0, s_t = 1, s_c = 1, m_t = 20, m_c = 20, 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, lower.tail = FALSE ) # Example 5: Uncontrolled design - posterior predictive probability pbayespostpred1cont( prob = 'predictive', design = 'uncontrolled', prior = 'vague', CalcMethod = 'MM', theta0 = 1.5, n_t = 15, n_c = NULL, bar_y_t = 3.5, bar_y_c = NULL, s_t = 1.2, s_c = NULL, mu0_c = 1.5, r = 1.2, kappa0_t = NULL, kappa0_c = NULL, nu0_t = NULL, nu0_c = NULL, mu0_t = NULL, sigma0_t = NULL, sigma0_c = NULL, m_t = 20, m_c = 20, 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, lower.tail = FALSE ) # Example 6: External design - posterior predictive probability pbayespostpred1cont( prob = 'predictive', design = 'external', prior = 'N-Inv-Chisq', CalcMethod = 'MM', theta0 = 1, n_t = 12, n_c = 12, kappa0_t = 5, kappa0_c = 5, nu0_t = 5, nu0_c = 5, mu0_t = 5, mu0_c = 5, sigma0_t = sqrt(5), sigma0_c = sqrt(5), bar_y_t = 2.5, bar_y_c = 1, s_t = 1.1, s_c = 0.9, m_t = 20, m_c = 20, r = NULL, ne_t = 10, ne_c = 10, alpha0e_t = 0.5, alpha0e_c = 0.5, bar_ye_t = 2, bar_ye_c = 0.5, se_t = 1, se_c = 0.8, lower.tail = FALSE )
Computes the Bayesian posterior probability or posterior predictive probability for clinical trials with two binary endpoints under a Dirichlet-multinomial conjugate model. The function returns probabilities for nine decision regions (posterior) or four decision regions (predictive) defined by target values (TV) and minimum acceptable values (MAV) for both endpoints. Three study designs are supported: controlled, uncontrolled (hypothetical control), and external (power prior).
pbayespostpred2bin( prob = "posterior", design = "controlled", theta_TV1 = NULL, theta_MAV1 = NULL, theta_TV2 = NULL, theta_MAV2 = NULL, theta_NULL1 = NULL, theta_NULL2 = NULL, x_t_00, x_t_01, x_t_10, x_t_11, x_c_00 = NULL, x_c_01 = NULL, x_c_10 = NULL, x_c_11 = NULL, a_t_00, a_t_01, a_t_10, a_t_11, a_c_00, a_c_01, a_c_10, a_c_11, 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 = 10000L )pbayespostpred2bin( prob = "posterior", design = "controlled", theta_TV1 = NULL, theta_MAV1 = NULL, theta_TV2 = NULL, theta_MAV2 = NULL, theta_NULL1 = NULL, theta_NULL2 = NULL, x_t_00, x_t_01, x_t_10, x_t_11, x_c_00 = NULL, x_c_01 = NULL, x_c_10 = NULL, x_c_11 = NULL, a_t_00, a_t_01, a_t_10, a_t_11, a_c_00, a_c_01, a_c_10, a_c_11, 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 = 10000L )
prob |
A character string specifying the probability type.
Must be |
design |
A character string specifying the trial design.
Must be |
theta_TV1 |
A numeric scalar giving the target value (TV) threshold
for Endpoint 1. Required when |
theta_MAV1 |
A numeric scalar giving the minimum acceptable value
(MAV) threshold for Endpoint 1. Required when
|
theta_TV2 |
A numeric scalar giving the target value (TV) threshold
for Endpoint 2. Required when |
theta_MAV2 |
A numeric scalar giving the minimum acceptable value
(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 |
x_t_00 |
A non-negative integer giving the count of
|
x_t_01 |
A non-negative integer giving the count of |
x_t_10 |
A non-negative integer giving the count of |
x_t_11 |
A non-negative integer giving the count of |
x_c_00 |
A non-negative integer giving the count of |
x_c_01 |
A non-negative integer giving the count of |
x_c_10 |
A non-negative integer giving the count of |
x_c_11 |
A non-negative integer giving the count of |
a_t_00 |
A positive numeric scalar giving the Dirichlet prior
parameter for the |
a_t_01 |
A positive numeric scalar giving the Dirichlet prior
parameter for the |
a_t_10 |
A positive numeric scalar giving the Dirichlet prior
parameter for the |
a_t_11 |
A positive numeric scalar giving the Dirichlet prior
parameter for the |
a_c_00 |
A positive numeric scalar giving the Dirichlet prior
parameter for the |
a_c_01 |
A positive numeric scalar giving the Dirichlet prior
parameter for the |
a_c_10 |
A positive numeric scalar giving the Dirichlet prior
parameter for the |
a_c_11 |
A positive numeric scalar giving the Dirichlet prior
parameter for the |
m_t |
A positive integer giving the number of patients in the
treatment group for the future trial. Required when
|
m_c |
A positive integer giving the number of patients in the
control group for the future trial. Required when
|
z00 |
A non-negative integer giving the hypothetical control count
for pattern |
z01 |
A non-negative integer giving the hypothetical control count
for pattern |
z10 |
A non-negative integer giving the hypothetical control count
for pattern |
z11 |
A non-negative integer giving the hypothetical control count
for pattern |
xe_t_00 |
A non-negative integer giving the external treatment group
count for pattern |
xe_t_01 |
A non-negative integer giving the external treatment group
count for pattern |
xe_t_10 |
A non-negative integer giving the external treatment group
count for pattern |
xe_t_11 |
A non-negative integer giving the external treatment group
count for pattern |
xe_c_00 |
A non-negative integer giving the external control group
count for pattern |
xe_c_01 |
A non-negative integer giving the external control group
count for pattern |
xe_c_10 |
A non-negative integer giving the external control group
count for pattern |
xe_c_11 |
A non-negative integer giving the external control group
count for pattern |
alpha0e_t |
A numeric scalar in |
alpha0e_c |
A numeric scalar in |
nMC |
A positive integer giving the number of Monte Carlo draws used
to estimate region probabilities. Default is |
Model. The four response categories are ordered as
(0, 0), (0, 1), (1, 0), (1, 1). For each
group , the observed count vector follows a multinomial
distribution, and a conjugate Dirichlet prior is placed on the cell
probability vector :
The posterior is
Marginal response rates are
(Endpoint 1) and (Endpoint 2).
Treatment effects are and
.
Uncontrolled design. When design = 'uncontrolled', the
hypothetical control distribution is specified as a Dirichlet
distribution directly via the prior hyperparameters and hypothetical
control counts z00, z01, z10, z11.
External design. When design = 'external', the power
prior augments the Dirichlet prior parameters.
A named numeric vector of region probabilities. For
prob = 'posterior': length 9, named R1, ...,
R9, corresponding to regions defined by TV and MAV
thresholds for both endpoints (row-major order: Endpoint 1 varies
slowest). For prob = 'predictive': length 4, named
R1, ..., R4. All elements are non-negative and sum
to 1.
# Example 1: Controlled design - posterior probability pbayespostpred2bin( prob = 'posterior', design = 'controlled', theta_TV1 = 0.15, theta_MAV1 = 0.05, theta_TV2 = 0.10, theta_MAV2 = 0.0, theta_NULL1 = NULL, theta_NULL2 = NULL, x_t_00 = 2, x_t_01 = 3, x_t_10 = 5, x_t_11 = 2, x_c_00 = 3, x_c_01 = 2, x_c_10 = 4, x_c_11 = 1, a_t_00 = 1, a_t_01 = 1, a_t_10 = 1, a_t_11 = 1, a_c_00 = 1, a_c_01 = 1, a_c_10 = 1, a_c_11 = 1, 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 ) # Example 2: Uncontrolled design - posterior probability pbayespostpred2bin( prob = 'posterior', design = 'uncontrolled', theta_TV1 = 0.15, theta_MAV1 = 0.05, theta_TV2 = 0.10, theta_MAV2 = 0.0, theta_NULL1 = NULL, theta_NULL2 = NULL, x_t_00 = 2, x_t_01 = 3, x_t_10 = 5, x_t_11 = 2, x_c_00 = NULL, x_c_01 = NULL, x_c_10 = NULL, x_c_11 = NULL, a_t_00 = 1, a_t_01 = 1, a_t_10 = 1, a_t_11 = 1, a_c_00 = 1, a_c_01 = 1, a_c_10 = 1, a_c_11 = 1, m_t = NULL, m_c = NULL, z00 = 1, z01 = 2, z10 = 2, z11 = 1, 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 ) # Example 3: External design - posterior probability pbayespostpred2bin( prob = 'posterior', design = 'external', theta_TV1 = 0.15, theta_MAV1 = 0.05, theta_TV2 = 0.10, theta_MAV2 = 0.0, theta_NULL1 = NULL, theta_NULL2 = NULL, x_t_00 = 2, x_t_01 = 3, x_t_10 = 5, x_t_11 = 2, x_c_00 = 3, x_c_01 = 2, x_c_10 = 4, x_c_11 = 1, a_t_00 = 1, a_t_01 = 1, a_t_10 = 1, a_t_11 = 1, a_c_00 = 1, a_c_01 = 1, a_c_10 = 1, a_c_11 = 1, m_t = NULL, m_c = NULL, z00 = NULL, z01 = NULL, z10 = NULL, z11 = NULL, xe_t_00 = 2, xe_t_01 = 2, xe_t_10 = 3, xe_t_11 = 1, xe_c_00 = 2, xe_c_01 = 1, xe_c_10 = 2, xe_c_11 = 1, alpha0e_t = 0.5, alpha0e_c = 0.5 ) # Example 4: Controlled design - posterior predictive probability pbayespostpred2bin( prob = 'predictive', design = 'controlled', theta_TV1 = NULL, theta_MAV1 = NULL, theta_TV2 = NULL, theta_MAV2 = NULL, theta_NULL1 = 0.05, theta_NULL2 = 0.0, x_t_00 = 2, x_t_01 = 3, x_t_10 = 5, x_t_11 = 2, x_c_00 = 3, x_c_01 = 2, x_c_10 = 4, x_c_11 = 1, a_t_00 = 1, a_t_01 = 1, a_t_10 = 1, a_t_11 = 1, a_c_00 = 1, a_c_01 = 1, a_c_10 = 1, a_c_11 = 1, m_t = 20, m_c = 20, 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 ) # Example 5: Uncontrolled design - posterior predictive probability pbayespostpred2bin( prob = 'predictive', design = 'uncontrolled', theta_TV1 = NULL, theta_MAV1 = NULL, theta_TV2 = NULL, theta_MAV2 = NULL, theta_NULL1 = 0.05, theta_NULL2 = 0.0, x_t_00 = 2, x_t_01 = 3, x_t_10 = 5, x_t_11 = 2, x_c_00 = NULL, x_c_01 = NULL, x_c_10 = NULL, x_c_11 = NULL, a_t_00 = 1, a_t_01 = 1, a_t_10 = 1, a_t_11 = 1, a_c_00 = 1, a_c_01 = 1, a_c_10 = 1, a_c_11 = 1, m_t = 20, m_c = 20, z00 = 1, z01 = 2, z10 = 2, z11 = 1, 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 ) # Example 6: External design - posterior predictive probability pbayespostpred2bin( prob = 'predictive', design = 'external', theta_TV1 = NULL, theta_MAV1 = NULL, theta_TV2 = NULL, theta_MAV2 = NULL, theta_NULL1 = 0.05, theta_NULL2 = 0.0, x_t_00 = 2, x_t_01 = 3, x_t_10 = 5, x_t_11 = 2, x_c_00 = 3, x_c_01 = 2, x_c_10 = 4, x_c_11 = 1, a_t_00 = 1, a_t_01 = 1, a_t_10 = 1, a_t_11 = 1, a_c_00 = 1, a_c_01 = 1, a_c_10 = 1, a_c_11 = 1, m_t = 20, m_c = 20, z00 = NULL, z01 = NULL, z10 = NULL, z11 = NULL, xe_t_00 = 2, xe_t_01 = 2, xe_t_10 = 3, xe_t_11 = 1, xe_c_00 = 2, xe_c_01 = 1, xe_c_10 = 2, xe_c_11 = 1, alpha0e_t = 0.5, alpha0e_c = 0.5 )# Example 1: Controlled design - posterior probability pbayespostpred2bin( prob = 'posterior', design = 'controlled', theta_TV1 = 0.15, theta_MAV1 = 0.05, theta_TV2 = 0.10, theta_MAV2 = 0.0, theta_NULL1 = NULL, theta_NULL2 = NULL, x_t_00 = 2, x_t_01 = 3, x_t_10 = 5, x_t_11 = 2, x_c_00 = 3, x_c_01 = 2, x_c_10 = 4, x_c_11 = 1, a_t_00 = 1, a_t_01 = 1, a_t_10 = 1, a_t_11 = 1, a_c_00 = 1, a_c_01 = 1, a_c_10 = 1, a_c_11 = 1, 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 ) # Example 2: Uncontrolled design - posterior probability pbayespostpred2bin( prob = 'posterior', design = 'uncontrolled', theta_TV1 = 0.15, theta_MAV1 = 0.05, theta_TV2 = 0.10, theta_MAV2 = 0.0, theta_NULL1 = NULL, theta_NULL2 = NULL, x_t_00 = 2, x_t_01 = 3, x_t_10 = 5, x_t_11 = 2, x_c_00 = NULL, x_c_01 = NULL, x_c_10 = NULL, x_c_11 = NULL, a_t_00 = 1, a_t_01 = 1, a_t_10 = 1, a_t_11 = 1, a_c_00 = 1, a_c_01 = 1, a_c_10 = 1, a_c_11 = 1, m_t = NULL, m_c = NULL, z00 = 1, z01 = 2, z10 = 2, z11 = 1, 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 ) # Example 3: External design - posterior probability pbayespostpred2bin( prob = 'posterior', design = 'external', theta_TV1 = 0.15, theta_MAV1 = 0.05, theta_TV2 = 0.10, theta_MAV2 = 0.0, theta_NULL1 = NULL, theta_NULL2 = NULL, x_t_00 = 2, x_t_01 = 3, x_t_10 = 5, x_t_11 = 2, x_c_00 = 3, x_c_01 = 2, x_c_10 = 4, x_c_11 = 1, a_t_00 = 1, a_t_01 = 1, a_t_10 = 1, a_t_11 = 1, a_c_00 = 1, a_c_01 = 1, a_c_10 = 1, a_c_11 = 1, m_t = NULL, m_c = NULL, z00 = NULL, z01 = NULL, z10 = NULL, z11 = NULL, xe_t_00 = 2, xe_t_01 = 2, xe_t_10 = 3, xe_t_11 = 1, xe_c_00 = 2, xe_c_01 = 1, xe_c_10 = 2, xe_c_11 = 1, alpha0e_t = 0.5, alpha0e_c = 0.5 ) # Example 4: Controlled design - posterior predictive probability pbayespostpred2bin( prob = 'predictive', design = 'controlled', theta_TV1 = NULL, theta_MAV1 = NULL, theta_TV2 = NULL, theta_MAV2 = NULL, theta_NULL1 = 0.05, theta_NULL2 = 0.0, x_t_00 = 2, x_t_01 = 3, x_t_10 = 5, x_t_11 = 2, x_c_00 = 3, x_c_01 = 2, x_c_10 = 4, x_c_11 = 1, a_t_00 = 1, a_t_01 = 1, a_t_10 = 1, a_t_11 = 1, a_c_00 = 1, a_c_01 = 1, a_c_10 = 1, a_c_11 = 1, m_t = 20, m_c = 20, 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 ) # Example 5: Uncontrolled design - posterior predictive probability pbayespostpred2bin( prob = 'predictive', design = 'uncontrolled', theta_TV1 = NULL, theta_MAV1 = NULL, theta_TV2 = NULL, theta_MAV2 = NULL, theta_NULL1 = 0.05, theta_NULL2 = 0.0, x_t_00 = 2, x_t_01 = 3, x_t_10 = 5, x_t_11 = 2, x_c_00 = NULL, x_c_01 = NULL, x_c_10 = NULL, x_c_11 = NULL, a_t_00 = 1, a_t_01 = 1, a_t_10 = 1, a_t_11 = 1, a_c_00 = 1, a_c_01 = 1, a_c_10 = 1, a_c_11 = 1, m_t = 20, m_c = 20, z00 = 1, z01 = 2, z10 = 2, z11 = 1, 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 ) # Example 6: External design - posterior predictive probability pbayespostpred2bin( prob = 'predictive', design = 'external', theta_TV1 = NULL, theta_MAV1 = NULL, theta_TV2 = NULL, theta_MAV2 = NULL, theta_NULL1 = 0.05, theta_NULL2 = 0.0, x_t_00 = 2, x_t_01 = 3, x_t_10 = 5, x_t_11 = 2, x_c_00 = 3, x_c_01 = 2, x_c_10 = 4, x_c_11 = 1, a_t_00 = 1, a_t_01 = 1, a_t_10 = 1, a_t_11 = 1, a_c_00 = 1, a_c_01 = 1, a_c_10 = 1, a_c_11 = 1, m_t = 20, m_c = 20, z00 = NULL, z01 = NULL, z10 = NULL, z11 = NULL, xe_t_00 = 2, xe_t_01 = 2, xe_t_10 = 3, xe_t_11 = 1, xe_c_00 = 2, xe_c_01 = 1, xe_c_10 = 2, xe_c_11 = 1, alpha0e_t = 0.5, alpha0e_c = 0.5 )
Computes the posterior or posterior predictive probability that the
bivariate treatment effect falls in each of
the 9 (posterior) or 4 (predictive) rectangular regions defined by the
decision thresholds.
pbayespostpred2cont( prob, design, prior, theta_TV1 = NULL, theta_MAV1 = NULL, theta_TV2 = NULL, theta_MAV2 = NULL, theta_NULL1 = NULL, theta_NULL2 = NULL, n_t, n_c = NULL, ybar_t, S_t, ybar_c = NULL, S_c = 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 = 10000L, CalcMethod = "MC" )pbayespostpred2cont( prob, design, prior, theta_TV1 = NULL, theta_MAV1 = NULL, theta_TV2 = NULL, theta_MAV2 = NULL, theta_NULL1 = NULL, theta_NULL2 = NULL, n_t, n_c = NULL, ybar_t, S_t, ybar_c = NULL, S_c = 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 = 10000L, CalcMethod = "MC" )
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 |
theta_TV1 |
A numeric scalar giving the target value (TV) threshold
for Endpoint 1. Required when |
theta_MAV1 |
A numeric scalar giving the minimum acceptable value
(MAV) threshold for Endpoint 1. Required when
|
theta_TV2 |
A numeric scalar giving the target value (TV) threshold
for Endpoint 2. Required when |
theta_MAV2 |
A numeric scalar giving the minimum acceptable value
(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 |
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 |
ybar_t |
A numeric vector of length 2 or a numeric matrix
with 2 columns giving the sample mean(s) for the treatment group.
When a matrix with |
S_t |
A 2x2 numeric matrix giving the sum-of-squares matrix for the
treatment group (single observation), or a list of |
ybar_c |
A numeric vector of length 2, a numeric matrix with 2
columns, or |
S_c |
A 2x2 numeric matrix, a list of 2x2 matrices, or |
m_t |
A positive integer giving the number of patients in the
treatment group for the future trial. Required when
|
m_c |
A positive integer giving the number of patients in the
control group for the future trial. Required when
|
kappa0_t |
A positive numeric scalar giving the NIW prior
concentration parameter for the treatment group. Required when
|
nu0_t |
A numeric scalar giving the NIW prior degrees of freedom for
the treatment group. Must be greater than 3. Required when
|
mu0_t |
A numeric vector of length 2 giving the NIW prior mean for
the treatment group. Required when
|
Lambda0_t |
A 2x2 positive-definite numeric matrix giving the NIW
prior scale matrix for the treatment group. Required when
|
kappa0_c |
A positive numeric scalar giving the NIW prior
concentration parameter for the control group. Required when
|
nu0_c |
A numeric scalar giving the NIW prior degrees of freedom for
the control group. Must be greater than 3. Required when
|
mu0_c |
A numeric vector of length 2 giving the NIW prior mean for
the control group, or the hypothetical control location when
|
Lambda0_c |
A 2x2 positive-definite numeric matrix giving the NIW
prior scale matrix for the control group. Required when
|
r |
A positive numeric scalar giving the variance scaling factor for
the hypothetical control distribution. Required when
|
ne_t |
A positive integer giving the external treatment group sample
size. Required when |
ne_c |
A positive integer giving the external control group sample
size. Required when |
alpha0e_t |
A numeric scalar in |
alpha0e_c |
A numeric scalar in |
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 |
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 |
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 |
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 |
nMC |
A positive integer giving the number of Monte Carlo draws used
to estimate region probabilities. Default is |
CalcMethod |
A character string specifying the computation method.
Must be |
Model.
Both endpoints follow a bivariate Normal distribution
for group .
The treatment effect is .
Posterior distribution (vague prior).
Posterior distribution (NIW prior).
with updated hyperparameters
,
,
, and
.
Predictive distribution.
The scale matrix of a single future observation is inflated by
(vague) or (NIW)
relative to the posterior. The mean of future observations has
scale divided by .
Posterior probability regions (prob = 'posterior'). Row-major 3x3 grid; Endpoint 1 varies slowest:
R1: AND
R2: AND
R3: AND
R4: AND
R5: AND
R6: AND
R7: AND
R8: AND
R9: AND
Predictive probability regions (prob = 'predictive'). Row-major 2x2 grid; Endpoint 1 varies slowest:
R1: AND
R2: AND
R3: AND
R4: AND
Uncontrolled design.
Under NIW prior:
.
The parameter r allows the variance scale of the hypothetical
control to differ from the treatment group.
External design.
Incorporated via the power prior with NIW conjugate representation.
The effective posterior hyperparameters are obtained by constructing the
power prior from external data with weight , then updating with
current PoC data (see Conjugate_power_prior.pdf, Theorem 5).
Vectorised usage.
When ybar_t is supplied as an matrix and
S_t as a list of scatter matrices, the function computes
region probabilities for all observations in a single call,
returning an matrix. For
CalcMethod = 'MC', standard normal and chi-squared variates are
pre-generated once (size nMC) and reused across all observations,
with only the Cholesky factor of the replicate-specific scale matrix
recomputed per observation. For CalcMethod = 'MM', the
moment-matching parameters are computed per observation (since they depend
on the replicate-specific ) and mvtnorm::pmvt is called
once per region per observation.
When ybar_t is a length-2 vector (single observation): a
named numeric vector of length 9 (R1–R9) for
prob = 'posterior' or length 4 (R1–R4) for
prob = 'predictive'. All elements are non-negative and sum
to 1.
When \code{ybar_t} is an \eqn{N \times 2} matrix (vectorised call):
a numeric matrix with \eqn{N} rows and 9 (or 4) columns, with
column names \code{R1}--\code{R9} (or \code{R1}--\code{R4}). Each
row sums to 1.
# Example 1: Controlled design - posterior probability, vague prior S_t <- matrix(c(18.0, 3.6, 3.6, 9.0), 2, 2) S_c <- matrix(c(16.0, 2.8, 2.8, 8.5), 2, 2) pbayespostpred2cont( prob = 'posterior', design = 'controlled', prior = 'vague', theta_TV1 = 1.5, theta_MAV1 = 0.5, theta_TV2 = 1.0, theta_MAV2 = 0.3, theta_NULL1 = NULL, theta_NULL2 = NULL, n_t = 12L, n_c = 12L, ybar_t = c(3.5, 2.1), S_t = S_t, ybar_c = c(1.8, 1.0), S_c = S_c, 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 = 1000L ) # Example 2: Uncontrolled design - posterior probability, NIW prior S_t <- matrix(c(18.0, 3.6, 3.6, 9.0), 2, 2) L0 <- matrix(c(20.0, 0.0, 0.0, 10.0), 2, 2) pbayespostpred2cont( prob = 'posterior', design = 'uncontrolled', prior = 'N-Inv-Wishart', theta_TV1 = 1.5, theta_MAV1 = 0.5, theta_TV2 = 1.0, theta_MAV2 = 0.3, theta_NULL1 = NULL, theta_NULL2 = NULL, n_t = 12L, n_c = NULL, ybar_t = c(3.5, 2.1), S_t = S_t, ybar_c = NULL, S_c = NULL, m_t = NULL, m_c = NULL, 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(1.0, 0.5), 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 = 1000L ) # Example 3: External design - posterior probability, NIW prior S_t <- matrix(c(18.0, 3.6, 3.6, 9.0), 2, 2) S_c <- matrix(c(16.0, 2.8, 2.8, 8.5), 2, 2) L0 <- matrix(c(20.0, 0.0, 0.0, 10.0), 2, 2) se_c <- matrix(c(15.0, 2.5, 2.5, 7.5), 2, 2) pbayespostpred2cont( prob = 'posterior', design = 'external', prior = 'N-Inv-Wishart', theta_TV1 = 1.5, theta_MAV1 = 0.5, theta_TV2 = 1.0, theta_MAV2 = 0.3, theta_NULL1 = NULL, theta_NULL2 = NULL, n_t = 12L, n_c = 12L, ybar_t = c(3.5, 2.1), S_t = S_t, ybar_c = c(1.8, 1.0), S_c = S_c, m_t = NULL, m_c = NULL, 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(1.0, 0.5), Lambda0_c = L0, r = NULL, ne_t = NULL, ne_c = 10L, alpha0e_t = NULL, alpha0e_c = 0.5, bar_ye_t = NULL, bar_ye_c = c(1.5, 0.8), se_t = NULL, se_c = se_c, nMC = 1000L ) # Example 4: Controlled design - posterior predictive probability, vague prior S_t <- matrix(c(18.0, 3.6, 3.6, 9.0), 2, 2) S_c <- matrix(c(16.0, 2.8, 2.8, 8.5), 2, 2) pbayespostpred2cont( prob = 'predictive', design = 'controlled', prior = 'vague', theta_TV1 = NULL, theta_MAV1 = NULL, theta_TV2 = NULL, theta_MAV2 = NULL, theta_NULL1 = 0.5, theta_NULL2 = 0.3, n_t = 12L, n_c = 12L, ybar_t = c(3.5, 2.1), S_t = S_t, ybar_c = c(1.8, 1.0), S_c = S_c, m_t = 30L, m_c = 30L, 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 = 1000L ) # Example 5: Uncontrolled design - posterior predictive probability, NIW prior S_t <- matrix(c(18.0, 3.6, 3.6, 9.0), 2, 2) L0 <- matrix(c(20.0, 0.0, 0.0, 10.0), 2, 2) pbayespostpred2cont( prob = 'predictive', design = 'uncontrolled', prior = 'N-Inv-Wishart', theta_TV1 = NULL, theta_MAV1 = NULL, theta_TV2 = NULL, theta_MAV2 = NULL, theta_NULL1 = 0.5, theta_NULL2 = 0.3, n_t = 12L, n_c = NULL, ybar_t = c(3.5, 2.1), S_t = S_t, ybar_c = NULL, S_c = NULL, m_t = 30L, m_c = 30L, 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(1.0, 0.5), 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 = 1000L ) # Example 6: External design - posterior predictive probability, NIW prior S_t <- matrix(c(18.0, 3.6, 3.6, 9.0), 2, 2) S_c <- matrix(c(16.0, 2.8, 2.8, 8.5), 2, 2) L0 <- matrix(c(20.0, 0.0, 0.0, 10.0), 2, 2) se_c <- matrix(c(15.0, 2.5, 2.5, 7.5), 2, 2) pbayespostpred2cont( prob = 'predictive', design = 'external', prior = 'N-Inv-Wishart', theta_TV1 = NULL, theta_MAV1 = NULL, theta_TV2 = NULL, theta_MAV2 = NULL, theta_NULL1 = 0.5, theta_NULL2 = 0.3, n_t = 12L, n_c = 12L, ybar_t = c(3.5, 2.1), S_t = S_t, ybar_c = c(1.8, 1.0), S_c = S_c, m_t = 30L, m_c = 30L, 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(1.0, 0.5), Lambda0_c = L0, r = NULL, ne_t = NULL, ne_c = 10L, alpha0e_t = NULL, alpha0e_c = 0.5, bar_ye_t = NULL, bar_ye_c = c(1.5, 0.8), se_t = NULL, se_c = se_c, nMC = 1000L )# Example 1: Controlled design - posterior probability, vague prior S_t <- matrix(c(18.0, 3.6, 3.6, 9.0), 2, 2) S_c <- matrix(c(16.0, 2.8, 2.8, 8.5), 2, 2) pbayespostpred2cont( prob = 'posterior', design = 'controlled', prior = 'vague', theta_TV1 = 1.5, theta_MAV1 = 0.5, theta_TV2 = 1.0, theta_MAV2 = 0.3, theta_NULL1 = NULL, theta_NULL2 = NULL, n_t = 12L, n_c = 12L, ybar_t = c(3.5, 2.1), S_t = S_t, ybar_c = c(1.8, 1.0), S_c = S_c, 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 = 1000L ) # Example 2: Uncontrolled design - posterior probability, NIW prior S_t <- matrix(c(18.0, 3.6, 3.6, 9.0), 2, 2) L0 <- matrix(c(20.0, 0.0, 0.0, 10.0), 2, 2) pbayespostpred2cont( prob = 'posterior', design = 'uncontrolled', prior = 'N-Inv-Wishart', theta_TV1 = 1.5, theta_MAV1 = 0.5, theta_TV2 = 1.0, theta_MAV2 = 0.3, theta_NULL1 = NULL, theta_NULL2 = NULL, n_t = 12L, n_c = NULL, ybar_t = c(3.5, 2.1), S_t = S_t, ybar_c = NULL, S_c = NULL, m_t = NULL, m_c = NULL, 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(1.0, 0.5), 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 = 1000L ) # Example 3: External design - posterior probability, NIW prior S_t <- matrix(c(18.0, 3.6, 3.6, 9.0), 2, 2) S_c <- matrix(c(16.0, 2.8, 2.8, 8.5), 2, 2) L0 <- matrix(c(20.0, 0.0, 0.0, 10.0), 2, 2) se_c <- matrix(c(15.0, 2.5, 2.5, 7.5), 2, 2) pbayespostpred2cont( prob = 'posterior', design = 'external', prior = 'N-Inv-Wishart', theta_TV1 = 1.5, theta_MAV1 = 0.5, theta_TV2 = 1.0, theta_MAV2 = 0.3, theta_NULL1 = NULL, theta_NULL2 = NULL, n_t = 12L, n_c = 12L, ybar_t = c(3.5, 2.1), S_t = S_t, ybar_c = c(1.8, 1.0), S_c = S_c, m_t = NULL, m_c = NULL, 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(1.0, 0.5), Lambda0_c = L0, r = NULL, ne_t = NULL, ne_c = 10L, alpha0e_t = NULL, alpha0e_c = 0.5, bar_ye_t = NULL, bar_ye_c = c(1.5, 0.8), se_t = NULL, se_c = se_c, nMC = 1000L ) # Example 4: Controlled design - posterior predictive probability, vague prior S_t <- matrix(c(18.0, 3.6, 3.6, 9.0), 2, 2) S_c <- matrix(c(16.0, 2.8, 2.8, 8.5), 2, 2) pbayespostpred2cont( prob = 'predictive', design = 'controlled', prior = 'vague', theta_TV1 = NULL, theta_MAV1 = NULL, theta_TV2 = NULL, theta_MAV2 = NULL, theta_NULL1 = 0.5, theta_NULL2 = 0.3, n_t = 12L, n_c = 12L, ybar_t = c(3.5, 2.1), S_t = S_t, ybar_c = c(1.8, 1.0), S_c = S_c, m_t = 30L, m_c = 30L, 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 = 1000L ) # Example 5: Uncontrolled design - posterior predictive probability, NIW prior S_t <- matrix(c(18.0, 3.6, 3.6, 9.0), 2, 2) L0 <- matrix(c(20.0, 0.0, 0.0, 10.0), 2, 2) pbayespostpred2cont( prob = 'predictive', design = 'uncontrolled', prior = 'N-Inv-Wishart', theta_TV1 = NULL, theta_MAV1 = NULL, theta_TV2 = NULL, theta_MAV2 = NULL, theta_NULL1 = 0.5, theta_NULL2 = 0.3, n_t = 12L, n_c = NULL, ybar_t = c(3.5, 2.1), S_t = S_t, ybar_c = NULL, S_c = NULL, m_t = 30L, m_c = 30L, 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(1.0, 0.5), 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 = 1000L ) # Example 6: External design - posterior predictive probability, NIW prior S_t <- matrix(c(18.0, 3.6, 3.6, 9.0), 2, 2) S_c <- matrix(c(16.0, 2.8, 2.8, 8.5), 2, 2) L0 <- matrix(c(20.0, 0.0, 0.0, 10.0), 2, 2) se_c <- matrix(c(15.0, 2.5, 2.5, 7.5), 2, 2) pbayespostpred2cont( prob = 'predictive', design = 'external', prior = 'N-Inv-Wishart', theta_TV1 = NULL, theta_MAV1 = NULL, theta_TV2 = NULL, theta_MAV2 = NULL, theta_NULL1 = 0.5, theta_NULL2 = 0.3, n_t = 12L, n_c = 12L, ybar_t = c(3.5, 2.1), S_t = S_t, ybar_c = c(1.8, 1.0), S_c = S_c, m_t = 30L, m_c = 30L, 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(1.0, 0.5), Lambda0_c = L0, r = NULL, ne_t = NULL, ne_c = 10L, alpha0e_t = NULL, alpha0e_c = 0.5, bar_ye_t = NULL, bar_ye_c = c(1.5, 0.8), se_t = NULL, se_c = se_c, nMC = 1000L )
Calculates the cumulative distribution function (CDF) of the difference
between two independent Beta-Binomial proportions by exact enumeration.
Specifically, computes or
, where
for
.
pbetabinomdiff( q, m_t, m_c, alpha_t, alpha_c, beta_t, beta_c, lower.tail = TRUE )pbetabinomdiff( q, m_t, m_c, alpha_t, alpha_c, beta_t, beta_c, lower.tail = TRUE )
q |
A numeric scalar representing the quantile threshold for the difference in proportions. |
m_t |
A positive integer giving the number of future patients in the treatment group. |
m_c |
A positive integer giving the number of future patients in the control group. |
alpha_t |
A positive numeric scalar giving the first shape parameter of the Beta mixing distribution for the treatment group. |
alpha_c |
A positive numeric scalar giving the first shape parameter of the Beta mixing distribution for the control group. |
beta_t |
A positive numeric scalar giving the second shape parameter of the Beta mixing distribution for the treatment group. |
beta_c |
A positive numeric scalar giving the second shape parameter of the Beta mixing distribution for the control group. |
lower.tail |
A logical scalar; if |
The probability mass function of
is:
where is the Beta function.
The exact CDF is obtained by enumerating all
outcome combinations and summing the joint
probabilities for which the proportion difference satisfies the specified
condition. Computation time therefore grows quadratically in and
; for large future sample sizes consider a normal approximation.
The Beta-Binomial distribution arises when the success probability in a Binomial model follows a Beta prior, making it appropriate for posterior predictive calculations in Bayesian binary-endpoint trials.
A numeric scalar in [0, 1].
# P((Y_t/12) - (Y_c/12) > 0.2) with symmetric Beta(0.5, 0.5) priors pbetabinomdiff(0.2, 12, 12, 0.5, 0.5, 0.5, 0.5, lower.tail = FALSE) # P((Y_t/20) - (Y_c/15) > 0.1) with different future sample sizes pbetabinomdiff(0.1, 20, 15, 1, 1, 1, 1, lower.tail = FALSE) # P((Y_t/10) - (Y_c/10) > 0) with informative priors pbetabinomdiff(0, 10, 10, 2, 3, 3, 2, lower.tail = FALSE) # Lower tail: P((Y_t/15) - (Y_c/15) <= 0.05) with vague priors pbetabinomdiff(0.05, 15, 15, 1, 1, 1, 1, lower.tail = TRUE)# P((Y_t/12) - (Y_c/12) > 0.2) with symmetric Beta(0.5, 0.5) priors pbetabinomdiff(0.2, 12, 12, 0.5, 0.5, 0.5, 0.5, lower.tail = FALSE) # P((Y_t/20) - (Y_c/15) > 0.1) with different future sample sizes pbetabinomdiff(0.1, 20, 15, 1, 1, 1, 1, lower.tail = FALSE) # P((Y_t/10) - (Y_c/10) > 0) with informative priors pbetabinomdiff(0, 10, 10, 2, 3, 3, 2, lower.tail = FALSE) # Lower tail: P((Y_t/15) - (Y_c/15) <= 0.05) with vague priors pbetabinomdiff(0.05, 15, 15, 1, 1, 1, 1, lower.tail = TRUE)
Calculates the cumulative distribution function (CDF) of the difference
between two independent Beta-distributed random variables. Specifically,
computes or , where
for
.
pbetadiff(q, alpha_t, alpha_c, beta_t, beta_c, lower.tail = TRUE)pbetadiff(q, alpha_t, alpha_c, beta_t, beta_c, lower.tail = TRUE)
q |
A numeric scalar in |
alpha_t |
A positive numeric scalar giving the first shape parameter of the Beta distribution for the treatment group. |
alpha_c |
A positive numeric scalar giving the first shape parameter of the Beta distribution for the control group. |
beta_t |
A positive numeric scalar giving the second shape parameter of the Beta distribution for the treatment group. |
beta_c |
A positive numeric scalar giving the second shape parameter of the Beta distribution for the control group. |
lower.tail |
A logical scalar; if |
The upper-tail probability is obtained via the convolution formula:
where is the density of
and is the CDF of
. Boundary cases are handled automatically by pbeta
( for , for ), so
integrating over [0, 1] is safe.
This single-integral convolution replaces an equivalent double-integral
formulation based on Appell's F1 hypergeometric function, yielding the
same result with lower computational cost because both pbeta and
dbeta are implemented in compiled C code.
A numeric scalar in [0, 1].
# P(pi_t - pi_c > 0.2) with symmetric Beta(0.5, 0.5) priors pbetadiff(0.2, 0.5, 0.5, 0.5, 0.5, lower.tail = FALSE) # P(pi_t - pi_c > -0.1) with informative priors pbetadiff(-0.1, 2, 1, 3, 4, lower.tail = FALSE) # P(pi_t - pi_c > 0) with equal priors -- should be approximately 0.5 pbetadiff(0, 1, 1, 1, 1, lower.tail = FALSE) # Lower tail: P(pi_t - pi_c <= 0.1) with symmetric priors pbetadiff(0.1, 2, 2, 2, 2, lower.tail = TRUE)# P(pi_t - pi_c > 0.2) with symmetric Beta(0.5, 0.5) priors pbetadiff(0.2, 0.5, 0.5, 0.5, 0.5, lower.tail = FALSE) # P(pi_t - pi_c > -0.1) with informative priors pbetadiff(-0.1, 2, 1, 3, 4, lower.tail = FALSE) # P(pi_t - pi_c > 0) with equal priors -- should be approximately 0.5 pbetadiff(0, 1, 1, 1, 1, lower.tail = FALSE) # Lower tail: P(pi_t - pi_c <= 0.1) with symmetric priors pbetadiff(0.1, 2, 2, 2, 2, lower.tail = TRUE)
Displays calibration curves of marginal Go and NoGo probabilities against
the threshold grid for results returned by
getgamma1bin.
## S3 method for class 'getgamma1bin' plot( x, title = NULL, col_go = "#658D1B", col_nogo = "#D91E49", base_size = 28, ... )## S3 method for class 'getgamma1bin' plot( x, title = NULL, col_go = "#658D1B", col_nogo = "#D91E49", base_size = 28, ... )
x |
An object of class |
title |
A character string for the plot title. Defaults to
|
col_go |
A character string specifying the colour for the Go curve.
Default is |
col_nogo |
A character string specifying the colour for the NoGo curve.
Default is |
base_size |
A positive numeric scalar specifying the base font size
(in points) passed to |
... |
Further arguments passed to or from other methods (ignored). |
The x-axis represents candidate threshold values .
The y-axis represents the marginal probability:
Go curve: evaluated
under the Go-calibration scenario (typically the Null scenario).
NoGo curve:
evaluated under the NoGo-calibration scenario (typically the
Alternative scenario).
Horizontal reference lines are drawn at target_go and
target_nogo. Filled circles (geom_point) mark the optimal
thresholds
and ,
with their values shown in the legend.
If either optimal threshold is NA, the corresponding point is omitted.
Invisibly returns a ggplot object.
Displays calibration curves of marginal Go and NoGo probabilities against
the threshold grid for results returned by
getgamma1cont.
## S3 method for class 'getgamma1cont' plot( x, title = NULL, col_go = "#658D1B", col_nogo = "#D91E49", base_size = 28, ... )## S3 method for class 'getgamma1cont' plot( x, title = NULL, col_go = "#658D1B", col_nogo = "#D91E49", base_size = 28, ... )
x |
An object of class |
title |
A character string for the plot title. Defaults to
|
col_go |
A character string specifying the colour for the Go curve.
Default is |
col_nogo |
A character string specifying the colour for the NoGo curve.
Default is |
base_size |
A positive numeric scalar specifying the base font size
(in points) passed to |
... |
Further arguments passed to or from other methods (ignored). |
The x-axis represents candidate threshold values .
The y-axis represents the marginal probability:
Go curve: evaluated
under the Go-calibration scenario (typically the Null scenario).
NoGo curve:
evaluated under the NoGo-calibration scenario (typically the
Alternative scenario).
Horizontal reference lines are drawn at target_go and
target_nogo. Filled circles (geom_point) mark the optimal
thresholds
and ,
with their values shown in the legend.
If either optimal threshold is NA, the corresponding point is omitted.
Invisibly returns a ggplot object.
Displays calibration curves of marginal Go and NoGo probabilities against
the threshold grid for results returned by
getgamma2bin.
## S3 method for class 'getgamma2bin' plot( x, title = NULL, col_go = "#658D1B", col_nogo = "#D91E49", base_size = 28, ... )## S3 method for class 'getgamma2bin' plot( x, title = NULL, col_go = "#658D1B", col_nogo = "#D91E49", base_size = 28, ... )
x |
An object of class |
title |
A character string for the plot title. Defaults to
|
col_go |
A character string specifying the colour for the Go curve.
Default is |
col_nogo |
A character string specifying the colour for the NoGo curve.
Default is |
base_size |
A positive numeric scalar specifying the base font size
(in points) passed to |
... |
Further arguments passed to or from other methods (ignored). |
The x-axis represents candidate threshold values .
The y-axis represents the marginal probability:
Go curve: evaluated
under the Go-calibration scenario (typically the Null scenario).
NoGo curve:
evaluated under the NoGo-calibration scenario (typically the
Alternative scenario).
Horizontal reference lines are drawn at target_go and
target_nogo. Filled circles (geom_point) mark the optimal
thresholds
and ,
with their values shown in the legend.
If either optimal threshold is NA, the corresponding point is omitted.
Invisibly returns a ggplot object.
Displays calibration curves of marginal Go and NoGo probabilities against
the threshold grid for results returned by
getgamma2cont.
## S3 method for class 'getgamma2cont' plot( x, title = NULL, col_go = "#658D1B", col_nogo = "#D91E49", base_size = 28, ... )## S3 method for class 'getgamma2cont' plot( x, title = NULL, col_go = "#658D1B", col_nogo = "#D91E49", base_size = 28, ... )
x |
An object of class |
title |
A character string for the plot title. Defaults to
|
col_go |
A character string specifying the colour for the Go curve.
Default is |
col_nogo |
A character string specifying the colour for the NoGo curve.
Default is |
base_size |
A positive numeric scalar specifying the base font size
(in points) passed to |
... |
Further arguments passed to or from other methods (ignored). |
The x-axis represents candidate threshold values .
The y-axis represents the marginal probability:
Go curve: evaluated
under the Go-calibration scenario (typically the Null scenario).
NoGo curve:
evaluated under the NoGo-calibration scenario (typically the
Alternative scenario).
Horizontal reference lines are drawn at target_go and
target_nogo. Filled circles (geom_point) mark the optimal
thresholds
and ,
with their values shown in the legend.
If either optimal threshold is NA, the corresponding point is omitted.
Invisibly returns a ggplot object.
Displays an operating characteristics curve of Go/NoGo/Gray decision
probabilities against the true treatment effect for binary endpoint results
returned by pbayesdecisionprob1bin.
## S3 method for class 'pbayesdecisionprob1bin' plot( x, title = NULL, xlab = NULL, col_go = "#658D1B", col_nogo = "#D91E49", col_gray = "#939597", base_size = 28, ... )## S3 method for class 'pbayesdecisionprob1bin' plot( x, title = NULL, xlab = NULL, col_go = "#658D1B", col_nogo = "#D91E49", col_gray = "#939597", base_size = 28, ... )
x |
An object of class |
title |
A character string for the plot title. Defaults to
|
xlab |
A character string or expression for the x-axis label.
Defaults to |
col_go |
A character string specifying the colour for the Go curve.
Default is |
col_nogo |
A character string specifying the colour for the NoGo curve.
Default is |
col_gray |
A character string specifying the colour for the Gray curve.
Default is |
base_size |
A positive numeric scalar specifying the base font size
(in points) passed to |
... |
Further arguments passed to or from other methods (ignored). |
For design = 'controlled' or design = 'external', the
x-axis represents the treatment-minus-control difference
, where is the mean
of the supplied pi_c values. For design = 'uncontrolled',
the x-axis represents directly.
Vertical reference lines are drawn at the decision thresholds:
When prob = 'posterior': lines at and
(converted to the x-axis scale).
When prob = 'predictive': a single line at .
Invisibly returns a ggplot object.
Displays an operating characteristics curve of Go/NoGo/Gray decision
probabilities against the true treatment effect for continuous endpoint
results returned by pbayesdecisionprob1cont.
## S3 method for class 'pbayesdecisionprob1cont' plot( x, title = NULL, xlab = NULL, col_go = "#658D1B", col_nogo = "#D91E49", col_gray = "#939597", base_size = 28, ... )## S3 method for class 'pbayesdecisionprob1cont' plot( x, title = NULL, xlab = NULL, col_go = "#658D1B", col_nogo = "#D91E49", col_gray = "#939597", base_size = 28, ... )
x |
An object of class |
title |
A character string for the plot title. Defaults to
|
xlab |
A character string or expression for the x-axis label.
Defaults to |
col_go |
A character string specifying the colour for the Go curve.
Default is |
col_nogo |
A character string specifying the colour for the NoGo curve.
Default is |
col_gray |
A character string specifying the colour for the Gray curve.
Default is |
base_size |
A positive numeric scalar specifying the base font size
(in points) passed to |
... |
Further arguments passed to or from other methods (ignored). |
For design = 'controlled' or design = 'external', the
x-axis represents the treatment-minus-control difference
, where is the mean
of the supplied mu_c values. For design = 'uncontrolled',
the x-axis represents directly.
Vertical reference lines are drawn at the decision thresholds:
When prob = 'posterior': lines at and
(converted to the x-axis scale).
When prob = 'predictive': a single line at .
Invisibly returns a ggplot object.
Displays operating characteristics for two-binary-endpoint results returned
by pbayesdecisionprob2bin.
## S3 method for class 'pbayesdecisionprob2bin' plot( x, which = "Go", title = NULL, xlab = NULL, ylab = NULL, col_go = "#658D1B", col_nogo = "#D91E49", col_gray = "#939597", base_size = 28, ... )## S3 method for class 'pbayesdecisionprob2bin' plot( x, which = "Go", title = NULL, xlab = NULL, ylab = NULL, col_go = "#658D1B", col_nogo = "#D91E49", col_gray = "#939597", base_size = 28, ... )
x |
An object of class |
which |
A character string specifying which decision probability to
plot. Must be one of |
title |
A character string for the plot title. Defaults to
|
xlab |
A character string or expression for the x-axis label.
Defaults to |
ylab |
A character string or expression for the y-axis label.
Defaults to |
col_go |
A character string specifying the high-end fill colour for the
Go probability gradient. Default is |
col_nogo |
A character string specifying the high-end fill colour for
the NoGo probability gradient. Default is |
col_gray |
A character string specifying the high-end fill colour for
the Gray probability gradient. Default is |
base_size |
A positive numeric scalar specifying the base font size
(in points) passed to |
... |
Further arguments passed to or from other methods (ignored). |
When the input scenarios form a regular grid over
(pi_t1, pi_t2) (i.e., every combination of the unique values of
pi_t1 and pi_t2 is present) and rho_t is constant,
the function produces a filled tile plot: each panel (Go, Gray,
NoGo) is coloured by its own probability on a continuous gradient (white to
the panel colour), so intensity directly reflects the probability magnitude.
A solid white contour line is overlaid at the corresponding decision
threshold (gamma_go for the Go panel, gamma_nogo for the
NoGo panel, and their mean for the Gray panel) to mark the boundary where
the probability equals the threshold. Otherwise the function falls back to
a scatter plot in which point colour encodes the decision
probability on a continuous scale.
When which = "all", the three panels are arranged side-by-side using
gridExtra::grid.arrange, so each panel retains its own independent
colour scale. This requires the gridExtra package.
For design = 'controlled' or design = 'external', both axes
are expressed as treatment-minus-control differences:
and
,
where and are the means of the
supplied pi_c1 and pi_c2 vectors.
For design = 'uncontrolled', the axes represent and
directly.
Vertical and horizontal reference lines are drawn at the decision thresholds:
When prob = 'posterior': vertical lines at
and (x-axis) and horizontal lines at
and (y-axis).
When prob = 'predictive': a single vertical line at
and a single horizontal line at
.
Invisibly returns a ggplot object (single panel) or a
gtable object (which = "all").
Displays operating characteristics for two-continuous-endpoint results
returned by pbayesdecisionprob2cont.
## S3 method for class 'pbayesdecisionprob2cont' plot( x, which = "Go", title = NULL, xlab = NULL, ylab = NULL, col_go = "#658D1B", col_nogo = "#D91E49", col_gray = "#939597", base_size = 28, ... )## S3 method for class 'pbayesdecisionprob2cont' plot( x, which = "Go", title = NULL, xlab = NULL, ylab = NULL, col_go = "#658D1B", col_nogo = "#D91E49", col_gray = "#939597", base_size = 28, ... )
x |
An object of class |
which |
A character string specifying which decision probability to
plot. Must be one of |
title |
A character string for the plot title. Defaults to
|
xlab |
A character string or expression for the x-axis label.
Defaults to |
ylab |
A character string or expression for the y-axis label.
Defaults to |
col_go |
A character string specifying the high-end fill colour for the
Go probability gradient. Default is |
col_nogo |
A character string specifying the high-end fill colour for
the NoGo probability gradient. Default is |
col_gray |
A character string specifying the high-end fill colour for
the Gray probability gradient. Default is |
base_size |
A positive numeric scalar specifying the base font size
(in points) passed to |
... |
Further arguments passed to or from other methods (ignored). |
When the input scenarios form a regular grid over
(mu_t1, mu_t2) (i.e., every combination of the unique values of
mu_t1 and mu_t2 is present) and rho_t is constant,
the function produces a filled tile plot: each panel (Go, Gray,
NoGo) is coloured by its own probability on a continuous gradient (white to
the panel colour), so intensity directly reflects the probability magnitude.
Otherwise the function falls back to a scatter plot in which point
colour encodes the decision probability on a continuous scale.
When which = "all", the three panels are arranged side-by-side using
gridExtra::grid.arrange, so each panel retains its own independent
colour scale. This requires the gridExtra package.
For design = 'controlled' or design = 'external', both axes
are expressed as treatment-minus-control differences:
and
,
where and are the means of the
supplied mu_c1 and mu_c2 vectors.
For design = 'uncontrolled', the axes represent and
directly.
Vertical and horizontal reference lines are drawn at the decision thresholds:
When prob = 'posterior': vertical lines at
and (x-axis) and horizontal lines at
and (y-axis).
When prob = 'predictive': a single vertical line at
and a single horizontal line at
.
Invisibly returns a ggplot object (single panel) or a
gtable object (which = "all").
Displays a formatted summary of Go/NoGo/Gray decision probabilities
for binary endpoint results returned by pbayesdecisionprob1bin.
## S3 method for class 'pbayesdecisionprob1bin' print(x, digits = 4, ...)## S3 method for class 'pbayesdecisionprob1bin' print(x, digits = 4, ...)
x |
An object of class |
digits |
A positive integer specifying the number of decimal places for probability values. Default is 4. |
... |
Further arguments passed to or from other methods (ignored). |
Invisibly returns x.
Displays a formatted summary of Go/NoGo/Gray decision probabilities
for continuous endpoint results returned by pbayesdecisionprob1cont.
## S3 method for class 'pbayesdecisionprob1cont' print(x, digits = 4, ...)## S3 method for class 'pbayesdecisionprob1cont' print(x, digits = 4, ...)
x |
An object of class |
digits |
A positive integer specifying the number of decimal places for probability values. Default is 4. |
... |
Further arguments passed to or from other methods (ignored). |
Invisibly returns x.
Displays a formatted summary of Go/NoGo/Gray decision probabilities for
two-binary-endpoint results returned by pbayesdecisionprob2bin.
## S3 method for class 'pbayesdecisionprob2bin' print(x, digits = 4, ...)## S3 method for class 'pbayesdecisionprob2bin' print(x, digits = 4, ...)
x |
An object of class |
digits |
A positive integer specifying the number of decimal places for probability values. Default is 4. |
... |
Further arguments passed to or from other methods (ignored). |
Invisibly returns x.
Displays a formatted summary of Go/NoGo/Gray decision probabilities for
two-continuous-endpoint results returned by
pbayesdecisionprob2cont.
Displays a formatted summary of Go/NoGo/Gray decision probabilities for
two-continuous-endpoint results returned by
pbayesdecisionprob2cont.
## S3 method for class 'pbayesdecisionprob2cont' print(x, digits = 4, ...) ## S3 method for class 'pbayesdecisionprob2cont' print(x, digits = 4, ...)## S3 method for class 'pbayesdecisionprob2cont' print(x, digits = 4, ...) ## S3 method for class 'pbayesdecisionprob2cont' print(x, digits = 4, ...)
x |
An object of class |
digits |
A positive integer specifying the number of decimal places for probability values. Default is 4. |
... |
Further arguments passed to or from other methods (ignored). |
Invisibly returns x.
Invisibly returns x.
Calculates the cumulative distribution function (CDF) of the difference
between two independent non-standardised t-distributed random variables
using Monte Carlo simulation. Specifically, computes
or , where
for .
ptdiff_MC(nMC, q, mu_t, mu_c, sd_t, sd_c, nu_t, nu_c, lower.tail = TRUE)ptdiff_MC(nMC, q, mu_t, mu_c, sd_t, sd_c, nu_t, nu_c, lower.tail = TRUE)
nMC |
A positive integer giving the number of Monte Carlo draws. Typical values range from 10,000 (quick estimates) to 100,000 or more (high precision). Larger values reduce Monte Carlo error at the cost of computation time. |
q |
A numeric scalar representing the quantile threshold. |
mu_t |
A numeric scalar or vector giving the location parameter of the t-distribution for the treatment group. |
mu_c |
A numeric scalar or vector giving the location parameter of the t-distribution for the control group. |
sd_t |
A positive numeric scalar or vector giving the scale parameter of the t-distribution for the treatment group. |
sd_c |
A positive numeric scalar or vector giving the scale parameter of the t-distribution for the control group. |
nu_t |
A numeric scalar giving the degrees of freedom of the t-distribution for the treatment group. Must be greater than 2 for finite variance. |
nu_c |
A numeric scalar giving the degrees of freedom of the t-distribution for the control group. Must be greater than 2 for finite variance. |
lower.tail |
A logical scalar; if |
The algorithm proceeds as follows:
Generate an nMC x n matrix of standard t draws for
( degrees of freedom), then scale and shift
each column by sd_t[i] and mu_t[i].
Repeat for with degrees of freedom.
Compute the nMC x n difference matrix
.
Return colMeans(D > q) as the estimated
for each parameter set.
All operations are matrix-based (no R-level loop over parameter sets), so
performance scales well with . However, note that the matrix size
is nMC x n, so memory usage grows linearly with both nMC
and . When is large (e.g., nsim x n_scenarios in
pbayesdecisionprob1cont), memory requirements can become
prohibitive; in such cases prefer CalcMethod = 'MM'.
Monte Carlo error is approximately
; near this is
roughly .
A numeric scalar or vector in [0, 1]. When mu_t,
mu_c, sd_t, or sd_c are vectors of length
, a vector of length is returned.
# P(T_t - T_c > 3) with equal parameters ptdiff_MC(nMC = 1e5, q = 3, mu_t = 2, mu_c = 0, sd_t = 1, sd_c = 1, nu_t = 17, nu_c = 17, lower.tail = FALSE) # P(T_t - T_c > 1) with unequal scales ptdiff_MC(nMC = 1e5, q = 1, mu_t = 5, mu_c = 3, sd_t = 2, sd_c = 1.5, nu_t = 10, nu_c = 15, lower.tail = FALSE) # P(T_t - T_c > 0) with different degrees of freedom ptdiff_MC(nMC = 1e5, q = 0, mu_t = 1, mu_c = 1, sd_t = 1, sd_c = 1, nu_t = 5, nu_c = 20, lower.tail = FALSE) # Lower tail: P(T_t - T_c <= 2) ptdiff_MC(nMC = 1e5, q = 2, mu_t = 3, mu_c = 0, sd_t = 1.5, sd_c = 1.2, nu_t = 12, nu_c = 15, lower.tail = TRUE) # Vectorised usage ptdiff_MC(nMC = 1e5, q = 1, mu_t = c(2, 3, 4), mu_c = c(0, 1, 2), sd_t = c(1, 1.2, 1.5), sd_c = c(1, 1.1, 1.3), nu_t = 10, nu_c = 10, lower.tail = FALSE)# P(T_t - T_c > 3) with equal parameters ptdiff_MC(nMC = 1e5, q = 3, mu_t = 2, mu_c = 0, sd_t = 1, sd_c = 1, nu_t = 17, nu_c = 17, lower.tail = FALSE) # P(T_t - T_c > 1) with unequal scales ptdiff_MC(nMC = 1e5, q = 1, mu_t = 5, mu_c = 3, sd_t = 2, sd_c = 1.5, nu_t = 10, nu_c = 15, lower.tail = FALSE) # P(T_t - T_c > 0) with different degrees of freedom ptdiff_MC(nMC = 1e5, q = 0, mu_t = 1, mu_c = 1, sd_t = 1, sd_c = 1, nu_t = 5, nu_c = 20, lower.tail = FALSE) # Lower tail: P(T_t - T_c <= 2) ptdiff_MC(nMC = 1e5, q = 2, mu_t = 3, mu_c = 0, sd_t = 1.5, sd_c = 1.2, nu_t = 12, nu_c = 15, lower.tail = TRUE) # Vectorised usage ptdiff_MC(nMC = 1e5, q = 1, mu_t = c(2, 3, 4), mu_c = c(0, 1, 2), sd_t = c(1, 1.2, 1.5), sd_c = c(1, 1.1, 1.3), nu_t = 10, nu_c = 10, lower.tail = FALSE)
Calculates the cumulative distribution function (CDF) of the difference
between two independent non-standardised t-distributed random variables
using a Moment-Matching approximation. Specifically, computes
or , where
for .
ptdiff_MM(q, mu_t, mu_c, sd_t, sd_c, nu_t, nu_c, lower.tail = TRUE)ptdiff_MM(q, mu_t, mu_c, sd_t, sd_c, nu_t, nu_c, lower.tail = TRUE)
q |
A numeric scalar representing the quantile threshold. |
mu_t |
A numeric scalar or vector giving the location parameter of the t-distribution for the treatment group. |
mu_c |
A numeric scalar or vector giving the location parameter of the t-distribution for the control group. |
sd_t |
A positive numeric scalar or vector giving the scale parameter of the t-distribution for the treatment group. |
sd_c |
A positive numeric scalar or vector giving the scale parameter of the t-distribution for the control group. |
nu_t |
A numeric scalar giving the degrees of freedom of the t-distribution for the treatment group. Must be greater than 4 for finite fourth moment. |
nu_c |
A numeric scalar giving the degrees of freedom of the t-distribution for the control group. Must be greater than 4 for finite fourth moment. |
lower.tail |
A logical scalar; if |
The difference is approximated by a single
non-standardised t-distribution
whose parameters are determined by
matching the first two even moments of :
.
is obtained from the second-moment equation.
is obtained from the fourth-moment equation.
The approximation requires and for
finite fourth moments. It is exact in the normal limit
() and works well in practice when .
Because it reduces to a single call to pt(), it is orders of
magnitude faster than the numerical integration method
(ptdiff_NI) and is fully vectorised.
A numeric scalar or vector in [0, 1]. When mu_t,
mu_c, sd_t, or sd_c are vectors of length
, a vector of length is returned.
# P(T_t - T_c > 3) with equal parameters ptdiff_MM(q = 3, mu_t = 2, mu_c = 0, sd_t = 1, sd_c = 1, nu_t = 17, nu_c = 17, lower.tail = FALSE) # P(T_t - T_c > 1) with unequal scales ptdiff_MM(q = 1, mu_t = 5, mu_c = 3, sd_t = 2, sd_c = 1.5, nu_t = 10, nu_c = 15, lower.tail = FALSE) # P(T_t - T_c > 0) with different degrees of freedom ptdiff_MM(q = 0, mu_t = 1, mu_c = 1, sd_t = 1, sd_c = 1, nu_t = 5, nu_c = 20, lower.tail = FALSE) # Lower tail: P(T_t - T_c <= 2) ptdiff_MM(q = 2, mu_t = 3, mu_c = 0, sd_t = 1.5, sd_c = 1.2, nu_t = 12, nu_c = 15, lower.tail = TRUE) # Vectorised usage ptdiff_MM(q = 1, mu_t = c(2, 3, 4), mu_c = c(0, 1, 2), sd_t = c(1, 1.2, 1.5), sd_c = c(1, 1.1, 1.3), nu_t = 10, nu_c = 10, lower.tail = FALSE)# P(T_t - T_c > 3) with equal parameters ptdiff_MM(q = 3, mu_t = 2, mu_c = 0, sd_t = 1, sd_c = 1, nu_t = 17, nu_c = 17, lower.tail = FALSE) # P(T_t - T_c > 1) with unequal scales ptdiff_MM(q = 1, mu_t = 5, mu_c = 3, sd_t = 2, sd_c = 1.5, nu_t = 10, nu_c = 15, lower.tail = FALSE) # P(T_t - T_c > 0) with different degrees of freedom ptdiff_MM(q = 0, mu_t = 1, mu_c = 1, sd_t = 1, sd_c = 1, nu_t = 5, nu_c = 20, lower.tail = FALSE) # Lower tail: P(T_t - T_c <= 2) ptdiff_MM(q = 2, mu_t = 3, mu_c = 0, sd_t = 1.5, sd_c = 1.2, nu_t = 12, nu_c = 15, lower.tail = TRUE) # Vectorised usage ptdiff_MM(q = 1, mu_t = c(2, 3, 4), mu_c = c(0, 1, 2), sd_t = c(1, 1.2, 1.5), sd_c = c(1, 1.1, 1.3), nu_t = 10, nu_c = 10, lower.tail = FALSE)
Calculates the cumulative distribution function (CDF) of the difference
between two independent non-standardised t-distributed random variables
using numerical integration. Specifically, computes
or , where
for .
ptdiff_NI(q, mu_t, mu_c, sd_t, sd_c, nu_t, nu_c, lower.tail = TRUE)ptdiff_NI(q, mu_t, mu_c, sd_t, sd_c, nu_t, nu_c, lower.tail = TRUE)
q |
A numeric scalar representing the quantile threshold. |
mu_t |
A numeric scalar or vector giving the location parameter of the t-distribution for the treatment group. |
mu_c |
A numeric scalar or vector giving the location parameter of the t-distribution for the control group. |
sd_t |
A positive numeric scalar or vector giving the scale parameter of the t-distribution for the treatment group. |
sd_c |
A positive numeric scalar or vector giving the scale parameter of the t-distribution for the control group. |
nu_t |
A numeric scalar giving the degrees of freedom of the t-distribution for the treatment group. Must be greater than 2 for finite variance. |
nu_c |
A numeric scalar giving the degrees of freedom of the t-distribution for the control group. Must be greater than 2 for finite variance. |
lower.tail |
A logical scalar; if |
The upper-tail probability is obtained via the convolution formula:
where is the density of
and is the CDF of .
The integral is evaluated by adaptive Gauss-Kronrod quadrature via
stats::integrate.
When the input parameters are vectors, mapply applies the scalar
integration function across all parameter sets.
Advantages:
Exact within numerical precision.
Handles arbitrary parameter combinations.
Computational note: this method is substantially slower than the
Moment-Matching approximation (ptdiff_MM) because it calls
integrate() once per parameter set. For large-scale simulation
(many parameter sets), prefer CalcMethod = 'MM' in
pbayesdecisionprob1cont.
A numeric scalar or vector in [0, 1]. When mu_t,
mu_c, sd_t, or sd_c are vectors of length
, a vector of length is returned.
# P(T_t - T_c > 3) with equal parameters ptdiff_NI(q = 3, mu_t = 2, mu_c = 0, sd_t = 1, sd_c = 1, nu_t = 17, nu_c = 17, lower.tail = FALSE) # P(T_t - T_c > 1) with unequal scales ptdiff_NI(q = 1, mu_t = 5, mu_c = 3, sd_t = 2, sd_c = 1.5, nu_t = 10, nu_c = 15, lower.tail = FALSE) # P(T_t - T_c > 0) with different degrees of freedom ptdiff_NI(q = 0, mu_t = 1, mu_c = 1, sd_t = 1, sd_c = 1, nu_t = 5, nu_c = 20, lower.tail = FALSE) # Lower tail: P(T_t - T_c <= 2) ptdiff_NI(q = 2, mu_t = 3, mu_c = 0, sd_t = 1.5, sd_c = 1.2, nu_t = 12, nu_c = 15, lower.tail = TRUE) # Vectorised usage ptdiff_NI(q = 1, mu_t = c(2, 3, 4), mu_c = c(0, 1, 2), sd_t = c(1, 1.2, 1.5), sd_c = c(1, 1.1, 1.3), nu_t = 10, nu_c = 10, lower.tail = FALSE)# P(T_t - T_c > 3) with equal parameters ptdiff_NI(q = 3, mu_t = 2, mu_c = 0, sd_t = 1, sd_c = 1, nu_t = 17, nu_c = 17, lower.tail = FALSE) # P(T_t - T_c > 1) with unequal scales ptdiff_NI(q = 1, mu_t = 5, mu_c = 3, sd_t = 2, sd_c = 1.5, nu_t = 10, nu_c = 15, lower.tail = FALSE) # P(T_t - T_c > 0) with different degrees of freedom ptdiff_NI(q = 0, mu_t = 1, mu_c = 1, sd_t = 1, sd_c = 1, nu_t = 5, nu_c = 20, lower.tail = FALSE) # Lower tail: P(T_t - T_c <= 2) ptdiff_NI(q = 2, mu_t = 3, mu_c = 0, sd_t = 1.5, sd_c = 1.2, nu_t = 12, nu_c = 15, lower.tail = TRUE) # Vectorised usage ptdiff_NI(q = 1, mu_t = c(2, 3, 4), mu_c = c(0, 1, 2), sd_t = c(1, 1.2, 1.5), sd_c = c(1, 1.1, 1.3), nu_t = 10, nu_c = 10, lower.tail = FALSE)
Generates random samples from a Dirichlet distribution using the Gamma
representation: if independently
for , then
,
where .
rdirichlet(n, alpha)rdirichlet(n, alpha)
n |
A positive integer specifying the number of random vectors to generate. |
alpha |
A numeric vector of length |
The Dirichlet distribution is a multivariate generalisation of the Beta distribution and is commonly used as a conjugate prior for multinomial proportions in Bayesian statistics.
The probability density function is:
where and .
Key properties:
Each marginal follows a Beta distribution:
.
.
Components are negatively correlated unless one component dominates.
Implementation steps:
Generate independent for
each .
Normalise: .
A numeric matrix of dimensions n x K where each row is one
random draw from the Dirichlet distribution, with all elements in
[0, 1] and each row summing to 1.
When n = 1, a numeric vector of length K is returned.
# Example 1: Generate 5 samples from Dirichlet(1, 1, 1) - uniform on simplex samples <- rdirichlet(5, c(1, 1, 1)) print(samples) rowSums(samples) # Each row should sum to 1 # Example 2: Generate samples with unequal concentrations samples <- rdirichlet(1000, c(2, 5, 3)) colMeans(samples) # Expected values: approximately c(0.2, 0.5, 0.3) # Example 3: Sparse Dirichlet (small alpha values) samples <- rdirichlet(100, c(0.1, 0.1, 0.1, 0.1)) head(samples) # Most weight concentrated on one component # Example 4: Concentrated Dirichlet (large alpha values) samples <- rdirichlet(100, c(100, 100, 100)) colMeans(samples) # Concentrated around c(1/3, 1/3, 1/3) # Example 5: Bayesian update with Jeffreys prior for 4 categories prior_alpha <- c(0.5, 0.5, 0.5, 0.5) observed_counts <- c(10, 5, 8, 7) posterior_samples <- rdirichlet(1000, prior_alpha + observed_counts) colMeans(posterior_samples) # Posterior mean# Example 1: Generate 5 samples from Dirichlet(1, 1, 1) - uniform on simplex samples <- rdirichlet(5, c(1, 1, 1)) print(samples) rowSums(samples) # Each row should sum to 1 # Example 2: Generate samples with unequal concentrations samples <- rdirichlet(1000, c(2, 5, 3)) colMeans(samples) # Expected values: approximately c(0.2, 0.5, 0.3) # Example 3: Sparse Dirichlet (small alpha values) samples <- rdirichlet(100, c(0.1, 0.1, 0.1, 0.1)) head(samples) # Most weight concentrated on one component # Example 4: Concentrated Dirichlet (large alpha values) samples <- rdirichlet(100, c(100, 100, 100)) colMeans(samples) # Concentrated around c(1/3, 1/3, 1/3) # Example 5: Bayesian update with Jeffreys prior for 4 categories prior_alpha <- c(0.5, 0.5, 0.5, 0.5) observed_counts <- c(10, 5, 8, 7) posterior_samples <- rdirichlet(1000, prior_alpha + observed_counts) colMeans(posterior_samples) # Posterior mean