
Bayesian Posterior or Posterior Predictive Probability for Two Binary Endpoints
Source:R/pbayespostpred2bin.R
pbayespostpred2bin.RdComputes 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).
Usage
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
)Arguments
- prob
A character string specifying the probability type. Must be
'posterior'or'predictive'.- design
A character string specifying the trial design. Must be
'controlled','uncontrolled', or'external'.- theta_TV1
A numeric scalar giving the target value (TV) threshold for Endpoint 1. Required when
prob = 'posterior'; must satisfytheta_TV1 > theta_MAV1. Set toNULLwhenprob = 'predictive'.- theta_MAV1
A numeric scalar giving the minimum acceptable value (MAV) threshold for Endpoint 1. Required when
prob = 'posterior'; must satisfytheta_TV1 > theta_MAV1. Set toNULLwhenprob = 'predictive'.- theta_TV2
A numeric scalar giving the target value (TV) threshold for Endpoint 2. Required when
prob = 'posterior'; must satisfytheta_TV2 > theta_MAV2. Set toNULLwhenprob = 'predictive'.- theta_MAV2
A numeric scalar giving the minimum acceptable value (MAV) threshold for Endpoint 2. Required when
prob = 'posterior'; must satisfytheta_TV2 > theta_MAV2. Set toNULLwhenprob = 'predictive'.- theta_NULL1
A numeric scalar giving the null hypothesis threshold for Endpoint 1. Required when
prob = 'predictive'; set toNULLwhenprob = 'posterior'.- theta_NULL2
A numeric scalar giving the null hypothesis threshold for Endpoint 2. Required when
prob = 'predictive'; set toNULLwhenprob = 'posterior'.- x_t_00
A non-negative integer giving the count of
(0, 0)responses in the treatment group (Endpoint 1 = 0, Endpoint 2 = 0).- x_t_01
A non-negative integer giving the count of
(0, 1)responses in the treatment group.- x_t_10
A non-negative integer giving the count of
(1, 0)responses in the treatment group.- x_t_11
A non-negative integer giving the count of
(1, 1)responses in the treatment group.- x_c_00
A non-negative integer giving the count of
(0, 0)responses in the control group. Not used whendesign = 'uncontrolled'; set toNULLin that case.- x_c_01
A non-negative integer giving the count of
(0, 1)responses in the control group. Not used whendesign = 'uncontrolled'; set toNULLin that case.- x_c_10
A non-negative integer giving the count of
(1, 0)responses in the control group. Not used whendesign = 'uncontrolled'; set toNULLin that case.- x_c_11
A non-negative integer giving the count of
(1, 1)responses in the control group. Not used whendesign = 'uncontrolled'; set toNULLin that case.- 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 giving the Dirichlet prior parameter for the
(0, 1)response pattern in the treatment group.- a_t_10
A positive numeric scalar giving the Dirichlet prior parameter for the
(1, 0)response pattern in the treatment group.- a_t_11
A positive numeric scalar giving the Dirichlet prior parameter for the
(1, 1)response pattern in the treatment group.- a_c_00
A positive numeric scalar giving the Dirichlet prior parameter for the
(0, 0)response pattern in the control group. Fordesign = 'uncontrolled', serves as a hyperparameter of the hypothetical control distribution.- a_c_01
A positive numeric scalar giving the Dirichlet prior parameter for the
(0, 1)response pattern in the control group. Fordesign = 'uncontrolled', serves as a hyperparameter of the hypothetical control distribution.- a_c_10
A positive numeric scalar giving the Dirichlet prior parameter for the
(1, 0)response pattern in the control group. Fordesign = 'uncontrolled', serves as a hyperparameter of the hypothetical control distribution.- a_c_11
A positive numeric scalar giving the Dirichlet prior parameter for the
(1, 1)response pattern in the control group. Fordesign = 'uncontrolled', serves as a hyperparameter of the hypothetical control distribution.- m_t
A positive integer giving the number of patients in the treatment group for the future trial. Required when
prob = 'predictive'; otherwise set toNULL.- m_c
A positive integer giving the number of patients in the control group for the future trial. Required when
prob = 'predictive'; otherwise set toNULL.- z00
A non-negative integer giving the hypothetical control count for pattern
(0, 0). Required whendesign = 'uncontrolled'; otherwise set toNULL.- z01
A non-negative integer giving the hypothetical control count for pattern
(0, 1). Required whendesign = 'uncontrolled'; otherwise set toNULL.- z10
A non-negative integer giving the hypothetical control count for pattern
(1, 0). Required whendesign = 'uncontrolled'; otherwise set toNULL.- z11
A non-negative integer giving the hypothetical control count for pattern
(1, 1). Required whendesign = 'uncontrolled'; otherwise set toNULL.- xe_t_00
A non-negative integer giving the external treatment group count for pattern
(0, 0). Required whendesign = 'external'and external treatment data are used; otherwiseNULL.- xe_t_01
A non-negative integer giving the external treatment group count for pattern
(0, 1). Required for external treatment data; otherwiseNULL.- xe_t_10
A non-negative integer giving the external treatment group count for pattern
(1, 0). Required for external treatment data; otherwiseNULL.- xe_t_11
A non-negative integer giving the external treatment group count for pattern
(1, 1). Required for external treatment data; otherwiseNULL.- xe_c_00
A non-negative integer giving the external control group count for pattern
(0, 0). Required whendesign = 'external'and external control data are used; otherwiseNULL.- xe_c_01
A non-negative integer giving the external control group count for pattern
(0, 1). Required for external control data; otherwiseNULL.- xe_c_10
A non-negative integer giving the external control group count for pattern
(1, 0). Required for external control data; otherwiseNULL.- xe_c_11
A non-negative integer giving the external control group count for pattern
(1, 1). Required for external control data; otherwiseNULL.- alpha0e_t
A numeric scalar in
(0, 1]giving the power prior weight for the external treatment data. Required when external treatment data are used; otherwise set toNULL.- alpha0e_c
A numeric scalar in
(0, 1]giving the power prior weight for the external control data. Required when external control data are used; otherwise set toNULL.- nMC
A positive integer giving the number of Monte Carlo draws used to estimate region probabilities. Default is
10000. Larger values reduce Monte Carlo error at the cost of computation time.
Value
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.
Details
Model. The four response categories are ordered as
(0, 0), (0, 1), (1, 0), (1, 1). For each
group \(j\), the observed count vector follows a multinomial
distribution, and a conjugate Dirichlet prior is placed on the cell
probability vector \(p_j\):
$$p_j \sim \mathrm{Dir}(\alpha_{j,00}, \alpha_{j,01}, \alpha_{j,10},
\alpha_{j,11}).$$
The posterior is
$$p_j \mid x_j \sim \mathrm{Dir}(\alpha_{j,00} + x_{j,00},
\alpha_{j,01} + x_{j,01}, \alpha_{j,10} + x_{j,10},
\alpha_{j,11} + x_{j,11}).$$
Marginal response rates are \(\pi_{j1} = p_{j,10} + p_{j,11}\) (Endpoint 1) and \(\pi_{j2} = p_{j,01} + p_{j,11}\) (Endpoint 2). Treatment effects are \(\theta_1 = \pi_{t1} - \pi_{c1}\) and \(\theta_2 = \pi_{t2} - \pi_{c2}\).
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.
Examples
# 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
)
#> R1 R2 R3 R4 R5 R6 R7 R8 R9
#> 0.1193 0.0696 0.1193 0.0961 0.0464 0.0742 0.2473 0.1058 0.1220
# 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
)
#> R1 R2 R3 R4 R5 R6 R7 R8 R9
#> 0.0481 0.0438 0.2314 0.0360 0.0367 0.1288 0.1218 0.0875 0.2659
# 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
)
#> R1 R2 R3 R4 R5 R6 R7 R8 R9
#> 0.0893 0.0667 0.1052 0.1026 0.0597 0.0793 0.2449 0.1194 0.1329
# 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
)
#> R1 R2 R3 R4
#> 0.2724 0.2408 0.3261 0.1607
# 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
)
#> R1 R2 R3 R4
#> 0.1590 0.3558 0.2059 0.2793
# 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
)
#> R1 R2 R3 R4
#> 0.2586 0.2373 0.3288 0.1753