| Type: | Package |
| Title: | Bayesian Quantitative Decision-Making Framework for Binary, Continuous and Time-to-Event Endpoints |
| Version: | 1.1.0 |
| Description: | Bayesian quantitative decision-making for proof-of-concept clinical trials with Go, NoGo and Gray decisions. A study is specified by its sample sizes, conjugate prior distributions, external data borrowed through power priors, a concurrent, external, hypothetical or fixed control group, and a decision criterion based on the posterior or posterior predictive probability of the treatment effect. The package computes the decision for observed data, the operating characteristics of one or more designs under scenarios for the true parameters, the decision thresholds, or the smallest sample size, for which the probabilities of false Go and false NoGo decisions are at most given targets, and the observed data that lead to each decision. Reports of a design and its results can be written as drafts of the corresponding sections of a study protocol. One or two binary endpoints (Beta-binomial and Dirichlet-multinomial models), one or two continuous endpoints (Normal-Inverse-chi-squared and Normal-Inverse-Wishart models) and one time-to-event endpoint evaluated by the milestone survival probability or the hazard ratio (exponential model with Gamma priors) are supported, with larger or smaller effects as favorable. The posterior distributions have closed forms, so Markov chain Monte Carlo (MCMC) sampling is not needed; the probabilities are computed from closed-form distribution functions, by exact summation, numerical integration, a moment-matching approximation or Monte Carlo simulation, with the main computations in C++. See Kang, Yamaguchi, and Han (2026) <doi:10.1080/10543406.2026.2655410> for the methodological framework. |
| License: | GPL-2 | GPL-3 [expanded from: GPL (≥ 2)] |
| Encoding: | UTF-8 |
| Language: | en-US |
| Depends: | R (≥ 4.1.0) |
| Imports: | ggplot2 (≥ 3.4.0), grDevices, Rcpp, stats, utils |
| LinkingTo: | Rcpp |
| Suggests: | knitr, rmarkdown, spelling, testthat (≥ 3.1.7) |
| VignetteBuilder: | knitr |
| Config/testthat/edition: | 3 |
| URL: | https://gosukehommaEX.github.io/BayesianQDM/, https://github.com/gosukehommaEX/BayesianQDM |
| BugReports: | https://github.com/gosukehommaEX/BayesianQDM/issues |
| Config/roxygen2/version: | 8.0.0 |
| NeedsCompilation: | yes |
| Packaged: | 2026-11-25 08:53:43 UTC; i_lik |
| Author: | Gosuke Homma [aut, cre], Yusuke Yamaguchi [aut] |
| Maintainer: | Gosuke Homma <my.name.is.gosuke@gmail.com> |
| Repository: | CRAN |
| Date/Publication: | 2026-11-25 09:20:02 UTC |
BayesianQDM: Bayesian Quantitative Decision-Making for Clinical Trials
Description
Tools for Go/NoGo/Gray decision-making in proof-of-concept clinical trials
under a Bayesian framework. A trial is described by small specification
objects (priors, data, external data with power priors, hypothetical
controls and decision criteria), and the decision rule is evaluated for
observed data or for its operating characteristics.
vignette("overview", package = "BayesianQDM") introduces the
package, and vignette("migration", package = "BayesianQDM") shows
how to translate code written for version 0.1.0.
Author(s)
Maintainer: Gosuke Homma my.name.is.gosuke@gmail.com
Authors:
Gosuke Homma my.name.is.gosuke@gmail.com
Yusuke Yamaguchi
See Also
Useful links:
Report bugs at https://github.com/gosukehommaEX/BayesianQDM/issues
Calibration as a data frame
Description
Converts a result of qdm_calibrate to a data frame with one
row: the chosen thresholds, the probabilities of meeting the criteria at
these thresholds and the targets. The probabilities for all candidate
thresholds are in the element curve of the result, which is a data
frame.
Usage
## S3 method for class 'qdm_calibration'
as.data.frame(x, row.names = NULL, optional = FALSE, ...)
Arguments
x |
An object of class |
row.names |
|
optional |
Not used. |
... |
Not used. |
Value
A data frame with one row and the columns gamma_go,
prob_go, target_go, gamma_nogo, prob_nogo
and target_nogo (see qdm_calibrate).
Examples
des <- design_binary(
n_t = 12, n_c = 12,
prior_t = prior_beta(0.5, 0.5), prior_c = prior_beta(0.5, 0.5),
criterion = criterion_posterior(theta_tv = 0.2, theta_mav = 0.1,
gamma_go = 0.5, gamma_nogo = 0.8)
)
cal <- qdm_calibrate(des,
scenario_go = data.frame(pi_t = 0.4, pi_c = 0.4),
scenario_nogo = data.frame(pi_t = 0.7, pi_c = 0.4),
target_go = 0.05, target_nogo = 0.2)
as.data.frame(cal)
Decision as a data frame
Description
Converts a result of qdm_decide to a data frame with one
row, so that the decisions for several data sets (for example for
subgroups, or for the prior distributions of a sensitivity analysis) can
be combined with rbind() and written to a file.
Usage
## S3 method for class 'qdm_decision'
as.data.frame(x, row.names = NULL, optional = FALSE, ..., posterior = FALSE)
Arguments
x |
An object of class |
row.names |
|
optional |
Not used. |
... |
Not used. |
posterior |
|
Details
The columns are decision; prob_go, gamma_go and
met_go (the probability of the Go criterion, its threshold and
whether the criterion is met); and prob_nogo, gamma_nogo
and met_nogo for the NoGo criterion. For two endpoints with a
marginal rule (rule = "and" or "or"), the probabilities and
the thresholds have one column per endpoint (prob_go1,
prob_go2, gamma_go1, gamma_go2, and so on), and
met_go and met_nogo combine the endpoints by the rule. For
two endpoints, the probabilities of the regions follow, in the columns
R1 to R9 (R1 to R4 for a predictive
criterion; see qdm_regions).
Value
A data frame with one row.
Examples
des <- design_binary(
n_t = 12, n_c = 12,
prior_t = prior_beta(0.5, 0.5), prior_c = prior_beta(0.5, 0.5),
criterion = criterion_posterior(theta_tv = 0.2, theta_mav = 0.1,
gamma_go = 0.5, gamma_nogo = 0.8)
)
dec1 <- qdm_decide(des, data_t = data_binary(12, 9),
data_c = data_binary(12, 4))
dec2 <- qdm_decide(des, data_t = data_binary(12, 6),
data_c = data_binary(12, 5))
rbind(as.data.frame(dec1), as.data.frame(dec2))
as.data.frame(dec1, posterior = TRUE)
Search for the sample size as a data frame
Description
Converts a result of qdm_find_n to a data frame with one
row: the chosen sample sizes, the probabilities of meeting the criteria
with them, the targets and the smallest sample sizes from which all
larger candidates meet the targets. The probabilities for all candidates
are in the element curve of the result, which is a data frame.
Usage
## S3 method for class 'qdm_n_search'
as.data.frame(x, row.names = NULL, optional = FALSE, ...)
Arguments
x |
An object of class |
row.names |
|
optional |
Not used. |
... |
Not used. |
Value
A data frame with one row and the columns n_t, n_c,
prob_go, target_go, prob_nogo, target_nogo,
n_t_stable and n_c_stable (see qdm_find_n).
Examples
des <- design_binary(
n_t = 12, n_c = 12,
prior_t = prior_beta(0.5, 0.5), prior_c = prior_beta(0.5, 0.5),
criterion = criterion_posterior(theta_tv = 0.2, theta_mav = 0.1,
gamma_go = 0.5, gamma_nogo = 0.8)
)
res <- qdm_find_n(des, data.frame(pi_t = 0.4, pi_c = 0.4),
data.frame(pi_t = 0.7, pi_c = 0.4), target_go = 0.1,
target_nogo = 0.1, n_t = seq(6, 20, by = 2))
as.data.frame(res)
External data borrowed through a power prior
Description
Specifies external (historical) data for one group together with the
power prior weight a_0. The likelihood of the external data is raised
to the power a_0, so that a_0 = 0 ignores the external data and
a_0 = 1 pools it with the current data. For the conjugate models used
in this package the resulting posterior distribution has a closed form, so
no Markov chain Monte Carlo sampling is needed.
Usage
borrow(data, a0)
Arguments
data |
External data created by |
a0 |
Power prior weight, a number from 0 to 1. |
Value
An object of class "qdm_borrow" with elements data and
a0.
Examples
borrow(data_binary(n = 20, y = 8), a0 = 0.5)
Joint cell probabilities of two binary endpoints
Description
Converts the marginal response rates of two binary endpoints and their correlation into the probabilities of the four joint response patterns.
Usage
cellprob_binary2(pi1, pi2, rho, tol = 1e-10)
Arguments
pi1 |
Response rate of endpoint 1, strictly between 0 and 1. |
pi2 |
Response rate of endpoint 2, strictly between 0 and 1. |
rho |
Correlation between the two endpoints. |
tol |
Tolerance for the feasibility check. |
Details
For two Bernoulli variables with response rates \pi_1 and
\pi_2, the Pearson correlation \rho determines
p_{11} = \pi_1 \pi_2 + \rho \sqrt{\pi_1 (1 - \pi_1) \pi_2 (1 - \pi_2)},
and p_{10} = \pi_1 - p_{11}, p_{01} = \pi_2 - p_{11},
p_{00} = 1 - p_{10} - p_{01} - p_{11}. All four probabilities are
non-negative only if
\max(0, \pi_1 + \pi_2 - 1) \le p_{11} \le \min(\pi_1, \pi_2), which
bounds the feasible range of \rho. An error is raised if rho
is outside this range by more than tol.
Value
A named numeric vector of the probabilities of the cells
"00", "01", "10" and "11" (first digit:
endpoint 1; second digit: endpoint 2), summing to 1.
See Also
Other distributions:
pbetabinomdiff(),
pbetadiff(),
phazardratio(),
psurvdiff(),
ptdiff(),
rdirichlet()
Examples
cellprob_binary2(pi1 = 0.3, pi2 = 0.4, rho = 0.3)
Conduct of a study with a time-to-event endpoint
Description
Specifies how subjects are enrolled, how they drop out and when the
analysis takes place. The operating characteristics of a design with a
time-to-event endpoint (design_tte) are computed by
simulating studies conducted in this way, and the posterior predictive
probabilities by simulating future studies.
Usage
conduct_tte(
accrual_time,
accrual_rate = rep(1, length(accrual_time) - 1L),
dropout_time = 0,
dropout_hazard = 0,
cut_time = NULL,
cut_events = NULL
)
Arguments
accrual_time |
Boundaries of the enrollment intervals: an increasing numeric vector that starts at 0, of length at least 2. |
accrual_rate |
Non-negative relative enrollment rates of the
intervals, one fewer than |
dropout_time |
Start times of the pieces of the dropout hazard: an increasing numeric vector that starts at 0. |
dropout_hazard |
Non-negative dropout hazards of the pieces, of the
same length as |
cut_time |
Calendar time of the analysis after the start of
enrollment (positive), or |
cut_events |
Number of events that triggers the analysis (a whole
number of at least 1), or |
Details
The subjects of all groups are enrolled at independent times with a
piecewise uniform distribution: the enrollment period is divided by
accrual_time, and the probability of an interval is proportional
to its rate in accrual_rate times its length (only the relative
rates matter). The dropout time of a subject, measured from enrollment,
has a piecewise exponential distribution with hazard
dropout_hazard[j] from time dropout_time[j] (the last hazard
applies until infinity), independently of the event time. The analysis
takes place at the calendar time cut_time after the start of
enrollment, or at the calendar time of the cut_events-th event
among all subjects of the study (if fewer events occur, all subjects are
followed until their event or dropout). A subject enrolled at time
e with event time T and dropout time C contributes the
observed time \min(T, C, \textrm{cut} - e) (0 if enrolled after the
analysis) and an event if T \le C and e + T \le \textrm{cut}.
Value
An object of class "qdm_conduct" with the arguments and the
element accrual_cum, the cumulative probabilities of enrollment
at the ends of the intervals.
See Also
Examples
# Enrollment over 15 months with increasing rates, dropout hazard 0.00226
# per month, analysis 15.44 months after the start of enrollment
conduct_tte(accrual_time = c(0, 5, 10, 15), accrual_rate = c(0.4, 2, 4.5),
dropout_hazard = 0.00226, cut_time = 15.44)
# Uniform enrollment over 12 months, analysis at the 20th event
conduct_tte(accrual_time = c(0, 12), cut_events = 20)
Decision criterion based on posterior probability
Description
Specifies a Go/NoGo decision criterion based on the posterior probability
of the treatment effect \theta (the difference between the treatment
and control groups, or their hazard ratio for a time-to-event endpoint)
given the proof-of-concept data D.
Usage
criterion_posterior(
theta_tv,
theta_mav,
gamma_go,
gamma_nogo,
go_regions = 1L,
nogo_regions = 9L,
rule = c("joint", "and", "or"),
direction = "greater"
)
Arguments
theta_tv |
Target value (TV) of the treatment effect: a number for one endpoint or a numeric vector of length 2 for two endpoints. |
theta_mav |
Minimum acceptable value (MAV) of the treatment effect, of
the same length as |
gamma_go |
Probability threshold for the Go criterion, strictly
between 0 and 1. With |
gamma_nogo |
Probability threshold for the NoGo criterion, strictly
between 0 and 1, given in the same way as |
go_regions |
Region numbers (from 1 to 9) forming the Go region for two
endpoints with |
nogo_regions |
Region numbers (from 1 to 9) forming the NoGo region for
two endpoints with |
rule |
For two endpoints, |
direction |
|
Details
For one endpoint, the Go region is \theta > \theta_{TV} and the NoGo
region is \theta \le \theta_{MAV}. The Go criterion is
\Pr(\theta > \theta_{TV} \mid D) \ge \gamma_{go} and the NoGo
criterion is \Pr(\theta \le \theta_{MAV} \mid D) \ge \gamma_{nogo}.
In the notation of Kang et al. (2026), where the NoGo criterion is
\Pr(\theta > \theta_{MAV} \mid D) \le \gamma_2, this corresponds to
\gamma_{nogo} = 1 - \gamma_2.
By default, larger effects are favorable (direction = "greater",
with \theta_{TV} > \theta_{MAV}), as for most efficacy endpoints.
For an endpoint on which smaller effects are favorable, such as the rate
of an adverse event or a hazard ratio, direction = "less" reverses
the inequalities (with \theta_{TV} < \theta_{MAV}): the Go region
is \theta < \theta_{TV}, the NoGo region is
\theta \ge \theta_{MAV}, and the criteria are
\Pr(\theta < \theta_{TV} \mid D) \ge \gamma_{go} and
\Pr(\theta \ge \theta_{MAV} \mid D) \ge \gamma_{nogo}.
For two endpoints, the target values and minimum acceptable values divide
the plane of (\theta_1, \theta_2) into nine regions (see
qdm_regions). The Go criterion is that the posterior
probability of the union of go_regions is at least
\gamma_{go}, and the NoGo criterion is that the posterior probability
of the union of nogo_regions is at least \gamma_{nogo}
(Yamaguchi et al., submitted, equations 2 and 3). With rule = "and"
or "or", the criteria are instead based on the marginal posterior
probabilities of each endpoint (equations 4 and 5): the Go criterion is
\Pr(\theta_1 > \theta_{TV1} \mid D) \ge \gamma_{go1} and (or)
\Pr(\theta_2 > \theta_{TV2} \mid D) \ge \gamma_{go2}, and the NoGo
criterion is \Pr(\theta_1 \le \theta_{MAV1} \mid D) \ge
\gamma_{nogo1} and (or)
\Pr(\theta_2 \le \theta_{MAV2} \mid D) \ge \gamma_{nogo2}.
With two endpoints, direction can differ between the endpoints,
for example an efficacy endpoint ("greater") and a safety endpoint
("less"). The regions are then defined on the favorable side of
each endpoint: region 1 has both effects beyond their target values in
the favorable direction (see qdm_regions).
The decision is Go if only the Go criterion is met, NoGo if only the NoGo
criterion is met, Gray if neither is met, and Miss if both are met. For one
endpoint, Miss can occur only when \gamma_{go} + \gamma_{nogo} \le 1.
Value
An object of class
c("qdm_criterion_posterior", "qdm_criterion").
References
Kang, R., Yamaguchi, Y. and Han, C. (2026). Bayesian quantitative decision-making framework in cell and gene therapy development for rare diseases. Journal of Biopharmaceutical Statistics. doi:10.1080/10543406.2026.2655410
Yamaguchi, Y., Hu, H., Huang, Y., Han, C., Homma, G. and Wang, A. (submitted). Bivariate Bayesian quantitative decision-making for two endpoints in rare disease drug development.
See Also
Other criteria:
criterion_predictive()
Examples
# One endpoint
criterion_posterior(theta_tv = 0.2, theta_mav = 0.1,
gamma_go = 0.5, gamma_nogo = 0.8)
# Two endpoints
criterion_posterior(theta_tv = c(0.2, 0.15), theta_mav = c(0.1, 0.05),
gamma_go = 0.3, gamma_nogo = 0.4)
# Two endpoints, marginal criteria combined with AND
criterion_posterior(theta_tv = c(0.2, 0.15), theta_mav = c(0.1, 0.05),
gamma_go = c(0.6, 0.5), gamma_nogo = 0.7, rule = "and")
# Rate of an adverse event: Go if it is likely to be reduced by more than
# 0.1, NoGo if it is likely not to be reduced
criterion_posterior(theta_tv = -0.1, theta_mav = 0, gamma_go = 0.6,
gamma_nogo = 0.7, direction = "less")
# Efficacy (larger is better) and safety (smaller is better) endpoints
criterion_posterior(theta_tv = c(0.2, -0.1), theta_mav = c(0.1, 0),
gamma_go = 0.5, gamma_nogo = 0.5,
direction = c("greater", "less"))
Decision criterion based on posterior predictive probability
Description
Specifies a Go/NoGo decision criterion based on the posterior predictive
probability of the treatment effect \tilde\theta that will be
observed in a future study with m_t and m_c subjects in the
treatment and control groups, given the proof-of-concept data D.
The future effect is the difference between the future sample proportions
(binary endpoints) or sample means (continuous endpoints), or, for a
time-to-event endpoint, the difference of the estimated milestone survival
probabilities or the ratio of the estimated hazards (see
design_tte).
Usage
criterion_predictive(
theta_null,
m_t,
m_c = m_t,
gamma_go,
gamma_nogo,
go_regions = 1L,
nogo_regions = 4L,
rule = c("joint", "and", "or"),
direction = "greater"
)
Arguments
theta_null |
Null value of the treatment effect in the future study: a number for one endpoint or a numeric vector of length 2 for two endpoints. |
m_t, m_c |
Numbers of subjects in the treatment and control groups of the future study (whole numbers of at least 1). |
gamma_go |
Probability threshold for the Go criterion, strictly
between 0 and 1. With |
gamma_nogo |
Probability threshold for the NoGo criterion, strictly
between 0 and 1, given in the same way as |
go_regions |
Region numbers (from 1 to 4) forming the Go region for two
endpoints with |
nogo_regions |
Region numbers (from 1 to 4) forming the NoGo region for
two endpoints with |
rule |
For two endpoints, |
direction |
|
Details
For one endpoint, the Go region is \tilde\theta > \theta_{NULL} and
the NoGo region is \tilde\theta \le \theta_{NULL}. The Go criterion
is \Pr(\tilde\theta > \theta_{NULL} \mid D) \ge \gamma_{go} and the
NoGo criterion is
\Pr(\tilde\theta \le \theta_{NULL} \mid D) \ge \gamma_{nogo}. Because
the two probabilities add up to 1, a Gray decision is possible only when
\gamma_{go} + \gamma_{nogo} > 1, and Miss decisions can occur only when
\gamma_{go} + \gamma_{nogo} \le 1.
With direction = "less", for an endpoint on which smaller effects
are favorable, the Go region is \tilde\theta < \theta_{NULL} and the
NoGo region is \tilde\theta \ge \theta_{NULL}.
For two endpoints, the null values divide the plane of
(\tilde\theta_1, \tilde\theta_2) into four regions (see
qdm_regions), and the criteria are based on the predictive
probabilities of the unions of go_regions and nogo_regions
(Yamaguchi et al., submitted, equations 7 and 8). With rule = "and"
or "or", they are based on the marginal predictive probabilities of
each endpoint, \Pr(\tilde\theta_k > \theta_{NULLk} \mid D) for Go
and \Pr(\tilde\theta_k \le \theta_{NULLk} \mid D) for NoGo,
combined with AND or OR (equations 9 and 10). With two endpoints,
direction can differ between the endpoints, and the regions are
defined on the favorable side of each endpoint.
Value
An object of class
c("qdm_criterion_predictive", "qdm_criterion").
References
Yamaguchi, Y., Hu, H., Huang, Y., Han, C., Homma, G. and Wang, A. (submitted). Bivariate Bayesian quantitative decision-making for two endpoints in rare disease drug development.
See Also
Other criteria:
criterion_posterior()
Examples
criterion_predictive(theta_null = 0, m_t = 50, gamma_go = 0.9,
gamma_nogo = 0.7)
# Smaller effects are favorable
criterion_predictive(theta_null = 0, m_t = 50, gamma_go = 0.9,
gamma_nogo = 0.7, direction = "less")
Binary endpoint data
Description
Summarizes the data of one group for a single binary endpoint as the number of subjects and the number of responders. Used for observed proof-of-concept data, external data and hypothetical control data.
Usage
data_binary(n, y)
Arguments
n |
Number of subjects (a whole number of at least 1). |
y |
Number of responders (a whole number from 0 to |
Value
An object of class c("qdm_data_binary", "qdm_data") with
integer elements n and y.
See Also
Other data:
data_binary2(),
data_continuous(),
data_continuous2(),
data_tte()
Examples
data_binary(n = 12, y = 7)
Data for two binary endpoints
Description
Summarizes the data of one group for two binary endpoints by the counts of the four joint response patterns.
Usage
data_binary2(counts)
Arguments
counts |
A numeric vector of four non-negative whole numbers in the
cell order |
Details
The cells are ordered as "00", "01", "10" and
"11", where the first digit is the response on endpoint 1 and the
second digit is the response on endpoint 2 (1 = response, 0 = no
response).
Value
An object of class c("qdm_data_binary2", "qdm_data") with
elements n (the total count) and counts (a named integer
vector of length 4).
See Also
Other data:
data_binary(),
data_continuous(),
data_continuous2(),
data_tte()
Examples
data_binary2(c(4, 2, 3, 6))
Continuous endpoint data
Description
Summarizes the data of one group for a single continuous endpoint by its
sufficient statistics: the number of subjects, the sample mean and the
sample standard deviation (with divisor n - 1).
Usage
data_continuous(n, mean, sd)
Arguments
n |
Number of subjects (a whole number of at least 2). |
mean |
Sample mean. |
sd |
Sample standard deviation (positive). |
Value
An object of class c("qdm_data_continuous", "qdm_data") with
elements n, mean and sd.
See Also
Other data:
data_binary(),
data_binary2(),
data_continuous2(),
data_tte()
Examples
data_continuous(n = 12, mean = 3.2, sd = 2.0)
Data for two continuous endpoints
Description
Summarizes the data of one group for two continuous endpoints by their
sufficient statistics: the number of subjects, the vector of sample means
and the sample covariance matrix (with divisor n - 1).
Usage
data_continuous2(n, mean, cov)
Arguments
n |
Number of subjects (a whole number of at least 3). |
mean |
Numeric vector of length 2, the sample means of endpoints 1 and 2. |
cov |
A 2 x 2 symmetric positive definite sample covariance matrix. |
Value
An object of class c("qdm_data_continuous2", "qdm_data")
with elements n, mean and cov.
See Also
Other data:
data_binary(),
data_binary2(),
data_continuous(),
data_tte()
Examples
data_continuous2(n = 12, mean = c(3.2, 1.5),
cov = matrix(c(4, 1.2, 1.2, 2), nrow = 2))
Time-to-event endpoint data
Description
Summarizes the data of one group for a time-to-event endpoint by the sufficient statistics of the exponential model: the number of events and the total observed time (the sum over subjects of the time from entry to the event or censoring). Used for observed proof-of-concept data, external data and hypothetical control data.
Usage
data_tte(events, exposure)
Arguments
events |
Number of events (a whole number of at least 0). |
exposure |
Total observed time (positive), in the same unit as the milestone time of the design. |
Details
With exponential event times and independent censoring, the likelihood of
the hazard \lambda is proportional to
\lambda^d \exp(-\lambda E) for d events and total observed
time E, so these two numbers are all that the analysis needs.
Value
An object of class c("qdm_data_tte", "qdm_data") with
elements events and exposure.
See Also
Other data:
data_binary(),
data_binary2(),
data_continuous(),
data_continuous2()
Examples
data_tte(events = 5, exposure = 40)
Design with one binary endpoint
Description
Specifies a proof-of-concept study with one binary endpoint: the sample
sizes, the prior distributions, the external data, the form of the control
group and the decision criterion. The design is used by
qdm_decide, qdm_oc, qdm_compare,
qdm_calibrate, qdm_find_n,
qdm_boundary and qdm_scenarios, and
show_report and show_code write it as a report
and as R code; the design steps (see qdm_endpoint) change one
part of it.
Usage
design_binary(
n_t,
n_c,
prior_t,
prior_c = NULL,
criterion,
external_t = NULL,
external_c = NULL,
hypothetical_c = NULL,
fixed_c = NULL
)
Arguments
n_t |
Number of subjects in the treatment group (a whole number of at least 1). |
n_c |
Number of subjects in the concurrent control group (a whole number of at least 0). |
prior_t, prior_c |
Beta prior distributions of the response rates of
the treatment and control groups, created by |
criterion |
Decision criterion for one endpoint, created by
|
external_t, external_c |
External data of the treatment and control
groups, created by |
hypothetical_c |
Hypothetical control, created by
|
fixed_c |
Fixed control response rate, a number from 0 to 1, or
|
Details
The response rates \pi_t and \pi_c of the treatment and control
groups have Beta prior distributions, and the treatment effect is
\theta = \pi_t - \pi_c. The control group takes one of four forms.
- Concurrent control
n_cis at least 1. External control data can be added throughexternal_c.- External control only
n_c = 0andexternal_cis given. The distribution of\pi_cis the posterior distribution given the external control data.- Hypothetical control
n_c = 0andhypothetical_cis given. The distribution of\pi_cis the posterior distribution given the hypothetical control data. The hypothetical control\pi_c \sim \textrm{Beta}(\alpha_t + z, \beta_t + n_t - z)of Kang et al. (2026, Section 4.1.4) is obtained withprior_cequal toprior_tandhypothetical(data_binary(n_t, z)).- Fixed control
n_c = 0andfixed_cis given: the control response rate is a known value\pi_c, as in a single-arm study compared with a benchmark. The posterior probabilities are\Pr(\pi_t > \theta_{TV} + \pi_c \mid D)and\Pr(\pi_t \le \theta_{MAV} + \pi_c \mid D), computed from the Beta posterior distribution of\pi_t(with the inequalities reversed fordirection = "less"). For the posterior predictive criterion the future effect isY_t / m_t - \pi_c, whereY_tfollows the Beta-binomial posterior predictive distribution (a future effect that differs from the null value by less than10^{-10}is treated as equal to it);m_cis not used.prior_cis not used and must beNULL.
External treatment data (external_t) can be used with any form of
the control group. External data enter through a power prior: with
external data of n_e subjects and y_e responders and weight
a_0, the posterior distribution of the response rate is
\textrm{Beta}(\alpha + a_0 y_e + y, \beta + a_0 (n_e - y_e) + n - y).
Value
An object of class c("qdm_design_binary", "qdm_design"), a
list with the arguments and the element control
("concurrent", "external", "hypothetical" or
"fixed").
References
Kang, R., Yamaguchi, Y. and Han, C. (2026). Bayesian quantitative decision-making framework in cell and gene therapy development for rare diseases. Journal of Biopharmaceutical Statistics. doi:10.1080/10543406.2026.2655410
See Also
Other designs:
design_binary2(),
design_continuous(),
design_continuous2(),
design_tte()
Examples
# Concurrent control with external control data
design_binary(
n_t = 12, n_c = 12,
prior_t = prior_beta(0.5, 0.5), prior_c = prior_beta(0.5, 0.5),
criterion = criterion_posterior(theta_tv = 0.2, theta_mav = 0.1,
gamma_go = 0.5, gamma_nogo = 0.8),
external_c = borrow(data_binary(n = 20, y = 8), a0 = 0.5)
)
# Uncontrolled study with a hypothetical control
design_binary(
n_t = 12, n_c = 0,
prior_t = prior_beta(0.5, 0.5), prior_c = prior_beta(0.5, 0.5),
criterion = criterion_predictive(theta_null = 0, m_t = 50,
gamma_go = 0.9, gamma_nogo = 0.7),
hypothetical_c = hypothetical(data = data_binary(n = 12, y = 4))
)
# Single-arm study compared with a fixed control response rate of 0.2
design_binary(
n_t = 20, n_c = 0, prior_t = prior_beta(1, 1),
criterion = criterion_posterior(theta_tv = 0.2, theta_mav = 0.05,
gamma_go = 0.8, gamma_nogo = 0.8),
fixed_c = 0.2
)
Design with two binary endpoints
Description
Specifies a proof-of-concept study with two binary endpoints: the sample
sizes, the Dirichlet prior distributions, the external data, the form of
the control group, the decision criterion for two endpoints and the
computation settings. The design is used by qdm_decide,
qdm_oc, qdm_compare,
qdm_calibrate, qdm_find_n and
qdm_scenarios, and show_report and
show_code write it as a report and as R code; the design
steps (see qdm_endpoint) change one part of it.
Usage
design_binary2(
n_t,
n_c,
prior_t,
prior_c = NULL,
criterion,
external_t = NULL,
external_c = NULL,
hypothetical_c = NULL,
fixed_c = NULL,
nMC = 10000L,
enumerate = TRUE
)
Arguments
n_t |
Number of subjects in the treatment group (a whole number of at least 1). |
n_c |
Number of subjects in the concurrent control group (a whole number of at least 0). |
prior_t, prior_c |
Dirichlet prior distributions of the four cell
probabilities of the treatment and control groups, created by
|
criterion |
Decision criterion for two endpoints, created by
|
external_t, external_c |
External data of the treatment and control
groups, created by |
hypothetical_c |
Hypothetical control, created by
|
fixed_c |
Fixed control response rates of endpoints 1 and 2, a numeric
vector of length 2 with values from 0 to 1, or |
nMC |
Number of Monte Carlo draws for posterior probabilities. |
enumerate |
Logical; if |
Details
The responses of a subject on the two endpoints fall into one of the four
cells "00", "01", "10" and "11" (first digit:
endpoint 1), whose probabilities have Dirichlet prior distributions in each
group (Yamaguchi et al., submitted, Appendix A.1). The treatment effects
are the differences of the marginal response rates,
\theta_k = \pi_{tk} - \pi_{ck} with \pi_1 = p_{10} + p_{11} and
\pi_2 = p_{01} + p_{11}. External data with counts x_e enter
through a power prior with weight a_0, which adds a_0 x_e to the
Dirichlet parameters. The control group takes one of four forms, as in
design_binary: a concurrent control group (n_c of at
least 1), external control data only (n_c = 0 and
external_c), a hypothetical control (n_c = 0 and
hypothetical_c created from data_binary2, whose counts
are added to prior_c; the hypothetical control distribution
Dir(beta) of Yamaguchi et al., Appendix A.1.6, is obtained with
prior_c = prior_dirichlet(beta - counts)), or a fixed control
(n_c = 0 and fixed_c, the known response rates of the two
endpoints in the control group; prior_c must then be NULL).
With a fixed control, the posterior probabilities are estimated from draws
of the treatment distribution only, and the future effects of the
predictive criterion are S_{tk} / m_t - \pi_{ck} (a future effect
that differs from the null value by less than 10^{-10} is treated as
equal to it; m_c is not used).
The posterior probabilities of the regions (posterior criteria) are
estimated by Monte Carlo simulation with nMC draws from the
Dirichlet posterior distributions. The posterior predictive probabilities
(predictive criteria) are computed exactly: the future effects depend only
on the numbers of responders on each endpoint, whose joint distribution in
each group is obtained from the Dirichlet-multinomial distribution, and a
future effect equal to a null value is not counted as larger.
For qdm_oc and qdm_calibrate, with
enumerate = TRUE all outcomes of the study are enumerated: there are
choose(n + 3, 3) outcomes in a group of n subjects (286 for
n = 10), and the probabilities of the regions are computed for
every pair of treatment and control outcomes, with the same Monte Carlo
draws for all pairs. For a posterior criterion the computing time is
proportional to the number of pairs times nMC, and enumeration is
limited to 1e7 pairs (for example, 24 subjects in each group). With
enumerate = FALSE, nsim studies are simulated under each
scenario, which is faster for large sample sizes.
Value
An object of class c("qdm_design_binary2", "qdm_design"),
a list with the arguments and the element control
("concurrent", "external", "hypothetical" or
"fixed").
References
Yamaguchi, Y., Hu, H., Huang, Y., Han, C., Homma, G. and Wang, A. (submitted). Bivariate Bayesian quantitative decision-making for two endpoints in rare disease drug development.
See Also
Other designs:
design_binary(),
design_continuous(),
design_continuous2(),
design_tte()
Examples
# Case study 1 of Yamaguchi et al. (submitted), with a small nMC for speed
des <- design_binary2(
n_t = 10, n_c = 10,
prior_t = prior_dirichlet(rep(0.25, 4)),
prior_c = prior_dirichlet(rep(0.25, 4)),
criterion = criterion_posterior(theta_tv = c(0.15, 0.15),
theta_mav = c(0.10, 0.10),
gamma_go = 0.263, gamma_nogo = 0.347),
nMC = 2000
)
des
qdm_decide(des, data_t = data_binary2(c(3, 2, 2, 3)),
data_c = data_binary2(c(6, 2, 1, 1)), seed = 1)
Design with one continuous endpoint
Description
Specifies a proof-of-concept study with one normally distributed endpoint:
the sample sizes, the prior distributions, the external data, the form of
the control group, the decision criterion and the method used to compute
the probabilities. The design is used by qdm_decide,
qdm_oc, qdm_compare,
qdm_calibrate, qdm_find_n,
qdm_boundary and qdm_scenarios, and
show_report and show_code write it as a report
and as R code; the design steps (see qdm_endpoint) change one
part of it.
Usage
design_continuous(
n_t,
n_c,
prior_t,
prior_c = NULL,
criterion,
external_t = NULL,
external_c = NULL,
hypothetical_c = NULL,
fixed_c = NULL,
method = c("NI", "MM", "MC"),
nMC = 10000L
)
Arguments
n_t |
Number of subjects in the treatment group (a whole number of at least 2). |
n_c |
Number of subjects in the concurrent control group: 0 (no concurrent control group) or a whole number of at least 2. |
prior_t, prior_c |
Prior distributions of the mean and variance of the
treatment and control groups, created by |
criterion |
Decision criterion for one endpoint, created by
|
external_t, external_c |
External data of the treatment and control
groups, created by |
hypothetical_c |
Hypothetical control, created by
|
fixed_c |
Fixed control mean, a number, or |
method |
Method used to compute the probabilities: |
nMC |
Number of Monte Carlo draws for |
Details
The outcomes of group k (k = t, c) follow
N(\mu_k, \sigma_k^2), and the treatment effect is
\theta = \mu_t - \mu_c. With the Normal-Inverse-chi-squared prior
(prior_nix), the posterior distribution of
(\mu_k, \sigma_k^2) is Normal-Inverse-chi-squared with parameters
(\mu_{nk}, \kappa_{nk}, \nu_{nk}, \sigma_{nk}^2), and the posterior
distribution of the mean is
t_{\nu_{nk}}(\mu_{nk}, \sigma_{nk}^2 / \kappa_{nk}). With the vague
prior (prior_vague) and n_k subjects with sample mean
\bar y_k and standard deviation s_k, it is
t_{n_k - 1}(\bar y_k, s_k^2 / n_k).
External data enter through a power prior with weight a_0: data with
n_e subjects, mean \bar y_e and standard deviation s_e
are combined with the prior as if they were a_0 n_e subjects with the
same mean and the sum of squares a_0 (n_e - 1) s_e^2. The posterior
distribution then has a closed form (Huang et al., submitted). With the
vague prior and external data, the posterior distribution of the mean has
a_0 n_e + n_k - 1 degrees of freedom.
The control group takes one of four forms.
- Concurrent control
n_cis at least 2. External control data can be added throughexternal_c.- External control only
n_c = 0andexternal_cis given. The distribution of\mu_cis the posterior distribution given the external control data. With the vague prior,a_0 n_emust be greater than 1.- Hypothetical control
n_c = 0andhypothetical_cis given byhypothetical(mean = mu0c, r = r). Following Kang et al. (2026, Section 4.2.4), the control mean has the same t distribution as the posterior distribution of the treatment mean, with location\mu_{0c}and squared scale multiplied byr:\mu_c \sim t_{\nu_{nt}}(\mu_{0c}, r \sigma_{nt}^2 / \kappa_{nt}).prior_cis not used and must beNULL.- Fixed control
n_c = 0andfixed_cis given: the control mean is a known value\mu_c, as in a single-arm study compared with a benchmark. The probabilities of the Go and NoGo regions are computed exactly from the t distribution of the treatment mean (posterior) or of the mean ofm_tfuture subjects (posterior predictive), shifted by\mu_c;method,nMCandm_care not used.prior_cis not used and must beNULL.
For the posterior predictive criterion (criterion_predictive),
the future effect is the difference between the sample means of m_t
and m_c future subjects. The posterior predictive distribution of the
mean of m future subjects of a group is
t_{\nu_{n}}(\mu_{n}, \sigma_{n}^2 (1 / \kappa_{n} + 1 / m)); for a
hypothetical control it is
t_{\nu_{nt}}(\mu_{0c}, r \sigma_{nt}^2 (1 / \kappa_{nt} + 1 / m_c)).
The probabilities of the Go and NoGo regions are probabilities of the
difference of two t variables, computed by ptdiff with the
chosen method. With method = "MC", the probabilities of the
two regions are estimated from the same nMC draws.
Value
An object of class c("qdm_design_continuous", "qdm_design"),
a list with the arguments and the element control
("concurrent", "external", "hypothetical" or
"fixed").
References
Kang, R., Yamaguchi, Y. and Han, C. (2026). Bayesian quantitative decision-making framework in cell and gene therapy development for rare diseases. Journal of Biopharmaceutical Statistics. doi:10.1080/10543406.2026.2655410
Huang, Y., Yamaguchi, Y., Homma, G., Takeda, K. and Maruo, K. (submitted). Conjugate representation of power priors for efficient Bayesian analysis of normal data.
See Also
Other designs:
design_binary(),
design_binary2(),
design_continuous2(),
design_tte()
Examples
# Concurrent control with external treatment and control data
design_continuous(
n_t = 12, n_c = 12,
prior_t = prior_vague(), prior_c = prior_vague(),
criterion = criterion_posterior(theta_tv = 30, theta_mav = 15,
gamma_go = 0.6, gamma_nogo = 0.7),
external_t = borrow(data_continuous(n = 6, mean = 20, sd = 30), a0 = 0.5),
external_c = borrow(data_continuous(n = 30, mean = -12, sd = 20),
a0 = 0.4)
)
# Uncontrolled study with a hypothetical control
design_continuous(
n_t = 12, n_c = 0, prior_t = prior_vague(),
criterion = criterion_predictive(theta_null = 0, m_t = 50,
gamma_go = 0.9, gamma_nogo = 0.7),
hypothetical_c = hypothetical(mean = -10, r = 1),
method = "MM"
)
# Single-arm study compared with a fixed control mean of -10
design_continuous(
n_t = 12, n_c = 0, prior_t = prior_vague(),
criterion = criterion_posterior(theta_tv = 30, theta_mav = 15,
gamma_go = 0.6, gamma_nogo = 0.7),
fixed_c = -10
)
Design with two continuous endpoints
Description
Specifies a proof-of-concept study with two continuous endpoints: the
sample sizes, the prior distributions, the external data, the form of the
control group, the decision criterion for two endpoints and the method
used to compute the probabilities. The design is used by
qdm_decide, qdm_oc, qdm_compare,
qdm_calibrate, qdm_find_n,
qdm_boundary and qdm_scenarios, and
show_report and show_code write it as a report
and as R code; the design steps (see qdm_endpoint) change one
part of it.
Usage
design_continuous2(
n_t,
n_c,
prior_t,
prior_c = NULL,
criterion,
external_t = NULL,
external_c = NULL,
hypothetical_c = NULL,
fixed_c = NULL,
method = c("MM", "MC"),
nMC = 10000L
)
Arguments
n_t |
Number of subjects in the treatment group (a whole number of at least 3). |
n_c |
Number of subjects in the concurrent control group: 0 or a whole number of at least 3. |
prior_t, prior_c |
Prior distributions of the treatment and control
groups, created by |
criterion |
Decision criterion for two endpoints, created by
|
external_t, external_c |
External data of the treatment and control
groups, created by |
hypothetical_c |
Hypothetical control, created by
|
fixed_c |
Fixed control means of endpoints 1 and 2, a numeric vector
of length 2, or |
method |
Method used to compute the probabilities: |
nMC |
Number of Monte Carlo draws for |
Details
The responses of a subject on the two endpoints have a bivariate normal
distribution with mean vector \mu_k and covariance matrix
\Sigma_k in group k (Yamaguchi et al., submitted, Appendix
A.2). The prior distribution of (\mu_k, \Sigma_k) is
Normal-Inverse-Wishart (prior_niw) or vague
(prior_vague, the density |\Sigma_k|^{-3/2}). External
data enter through a power prior with weight a_0, which has the
conjugate form, and the posterior parameters are updated with the external
data and then with the current data. The vague prior corresponds to
\kappa_0 = 0, \nu_0 = -1 and \Lambda_0 = 0, so the
posterior distribution of the mean is
t_{n - 2}(\bar y, S / (n (n - 2))) without external data, where
S is the matrix of sums of squares and cross-products, n - 1
times the sample covariance matrix (Yamaguchi et al., submitted,
equation A.9).
The treatment effects are the differences of the means,
\theta_k = \mu_{tk} - \mu_{ck}. The mean of each group has a
bivariate t distribution with \nu_n - 1 degrees of freedom,
location \mu_n and scale matrix
\Lambda_n / (\kappa_n (\nu_n - 1)). For a predictive criterion,
the mean of m future subjects has the same distribution with the
scale matrix (1 / \kappa_n + 1 / m) \Lambda_n / (\nu_n - 1),
because the future subjects share the same mean and covariance matrix
(version 0.1.0 used the scale matrix
(1 + \kappa_n) \Lambda_n / (\kappa_n (\nu_n - 1) m), which treats
them as independent draws from the predictive distribution of one
subject). A hypothetical control (hypothetical(mean = c(m1, m2),
r = r)) gives the control mean the distribution of the treatment mean
with location mean and the scale matrix multiplied by r
(Yamaguchi et al., Section A.2.6, with the hyperparameters of the
treatment group). With external control data only (n_c = 0 and
external_c) and the vague prior, a_0 n_e must be greater
than 2. A fixed control (n_c = 0 and fixed_c, the known
control means of the two endpoints) shifts the distribution of the
treatment mean, so the effect has a bivariate t distribution and the
probabilities of the regions are computed exactly from its distribution
function; method, nMC and m_c are then not used,
and prior_c must be NULL.
The probabilities of the regions are computed by one of two methods:
"MM"moment-matching approximation: the effect is approximated by a bivariate t distribution with the same mean, covariance matrix and radial fourth moment (Yamaguchi, Homma, Takeda and Maruo, submitted, Theorem 3), whose rectangle probabilities are computed by numerical integration, also for non-integer degrees of freedom. It requires more than 4 degrees of freedom for both groups and is the fastest method.
"MC"Monte Carlo simulation with
nMCdraws from each distribution; the probabilities of all regions are estimated from the same draws. The computing time is proportional tonMC, so"MM"is much faster for operating characteristics, which need the probabilities for many simulated studies.
The operating characteristics are computed by simulating the sample means
and the sums of squares and cross-products of nsim studies (see
qdm_oc).
Value
An object of class c("qdm_design_continuous2",
"qdm_design"), a list with the arguments and the element
control ("concurrent", "external",
"hypothetical" or "fixed").
References
Yamaguchi, Y., Hu, H., Huang, Y., Han, C., Homma, G. and Wang, A. (submitted). Bivariate Bayesian quantitative decision-making for two endpoints in rare disease drug development.
Yamaguchi, Y., Homma, G., Takeda, K. and Maruo, K. (submitted). Moment-matching approximation for t-differences in clinical trials with continuous endpoints.
See Also
Other designs:
design_binary(),
design_binary2(),
design_continuous(),
design_tte()
Examples
# Case study 2 of Yamaguchi et al. (submitted)
L0 <- matrix(c(80^2, 15, 15, 6^2), 2, 2)
des <- design_continuous2(
n_t = 30, n_c = 30,
prior_t = prior_niw(mu0 = c(0, 1), kappa0 = 0.1, nu0 = 4, Lambda0 = L0),
prior_c = prior_niw(mu0 = c(-10, -1), kappa0 = 0.1, nu0 = 4,
Lambda0 = L0),
criterion = criterion_posterior(theta_tv = c(10, 2),
theta_mav = c(5, 1),
gamma_go = 0.296, gamma_nogo = 0.244)
)
des
qdm_decide(des,
data_t = data_continuous2(30, c(5, 2),
matrix(c(6400, 190, 190, 36), 2, 2)),
data_c = data_continuous2(30, c(-10, -1),
matrix(c(5600, 150, 150, 42), 2, 2)))
Design with one time-to-event endpoint
Description
Specifies a proof-of-concept study with one time-to-event endpoint
evaluated by the milestone survival probability or by the hazard ratio:
the sample sizes, the prior distributions, the external data, the form of
the control group, the decision criterion, the effect measure and the
conduct of the study.
The design is used by qdm_decide, qdm_oc,
qdm_compare, qdm_calibrate,
qdm_find_n, qdm_boundary and
qdm_scenarios, and show_report and
show_code write it as a report and as R code; the design
steps (see qdm_endpoint) change one part of it.
Usage
design_tte(
n_t,
n_c,
prior_t,
prior_c = NULL,
criterion,
milestone = NULL,
effect = c("milestone", "hazard_ratio"),
conduct = NULL,
external_t = NULL,
external_c = NULL,
hypothetical_c = NULL,
fixed_c = NULL,
conduct_future = conduct,
nMC = 10000L
)
Arguments
n_t |
Number of subjects in the treatment group (a whole number of at least 1). |
n_c |
Number of subjects in the concurrent control group (a whole number of at least 0). |
prior_t, prior_c |
Gamma prior distributions of the hazards of the
treatment and control groups, created by |
criterion |
Decision criterion for one endpoint, created by
|
milestone |
Milestone time |
effect |
Effect measure: |
conduct |
Conduct of the study, created by |
external_t, external_c |
External data of the treatment and control
groups, created by |
hypothetical_c |
Hypothetical control, created by
|
fixed_c |
Fixed control milestone survival probability, a number from
0 to 1 ( |
conduct_future |
Conduct of the future study for a predictive
criterion, created by |
nMC |
Number of simulated future studies for posterior predictive probabilities. |
Details
The event times of group k (k = t, c) are exponential with
hazard \lambda_k, which has a Gamma prior distribution
(prior_gamma). The data of a group are summarized by the
number of events d and the total observed time E
(data_tte), and the posterior distribution of the hazard is
Gamma with shape a + d and rate b + E. External data enter
through a power prior with weight a_0, which adds a_0 d_e to the
shape and a_0 E_e to the rate. The treatment effect is either
effect = "milestone"the difference of the milestone survival probabilities at time
t_0 =milestone,\theta = S_t(t_0) - S_c(t_0)withS_k(t_0) = \exp(-\lambda_k t_0), oreffect = "hazard_ratio"the hazard ratio
\theta = \lambda_t / \lambda_c, as in Huang et al. (2019), whose decision rules are based on the normal approximation of the estimated log hazard ratio. Smaller hazard ratios are favorable, so the criterion is usually specified withdirection = "less", for exampletheta_tv = 0.67andtheta_mav = 0.8. Under the exponential model the hazard ratio is also the ratio of the median survival times of the control and treatment groups.
The control group takes one of four forms.
- Concurrent control
n_cis at least 1. External control data can be added throughexternal_c.- External control only
n_c = 0andexternal_cis given. The distribution of\lambda_cis the posterior distribution given the external control data.- Hypothetical control
n_c = 0andhypothetical_cis given byhypothetical(data_tte(events, exposure)), whose events and total observed time are added toprior_c.- Fixed control
n_c = 0andfixed_cis given: the control milestone survival probability (effect = "milestone") or the control median survival time (effect = "hazard_ratio", control hazard\log(2)/fixed_c) is a known value, as in a single-arm study compared with a benchmark (with the milestone survival,fixed_c = 0makes the effect the treatment milestone survival itself).prior_cis not used and must beNULL.
Posterior probabilities of the Go and NoGo regions are computed exactly
for a fixed control (from the Gamma distribution of \lambda_t). With
another control, they are computed by numerical integration for the
milestone survival (see psurvdiff) and exactly from the F
distribution for the hazard ratio (see phazardratio).
For the posterior predictive criterion (criterion_predictive),
a future study with m_t treatment and m_c control subjects
(no control group for a fixed control) is conducted as specified by
conduct_future. The hazard of each group in the future study is
estimated by (a + d) / (b + E), the posterior mean of the hazard
given the future data alone with the prior (a, b) of the group
(prior_t or prior_c); with a weak prior this is close to the
maximum likelihood estimate d / E and, unlike it, is positive when a
group has no events, so that the hazard ratio is defined. The milestone
survival is estimated by \exp(-t_0 (a + d) / (b + E)). The future
effect is the difference
of the two milestone survival estimates (or the treatment estimate minus
the fixed value), or the ratio of the two hazard estimates (or the
treatment estimate divided by the fixed control hazard). The predictive
probabilities are estimated by simulating nMC future studies,
each with hazards drawn from the posterior
distributions given the proof-of-concept data (see
conduct_tte for the simulation of a study). They are
therefore Monte Carlo estimates, and their computing time is proportional
to nMC times the number of future subjects.
The operating characteristics (qdm_oc,
qdm_calibrate) are computed by simulating nsim
studies conducted as specified by conduct, with exponential event
times whose hazards are given by the median survival times of the
scenarios. With a predictive criterion, every simulated study requires
nMC simulated future studies, so small values of nsim and
nMC are advisable for exploration.
Value
An object of class c("qdm_design_tte", "qdm_design"), a
list with the arguments and the element control
("concurrent", "external", "hypothetical" or
"fixed").
References
Huang, B., Talukder, E., Han, L. and Kuan, P.-F. (2019). Quantitative decision-making in randomized Phase II studies with a time-to-event endpoint. Journal of Biopharmaceutical Statistics, 29(1), 189–202. doi:10.1080/10543406.2018.1489400
See Also
Other designs:
design_binary(),
design_binary2(),
design_continuous(),
design_continuous2()
Examples
# Single-arm study compared with a fixed control 3-month survival of 0.72
des <- design_tte(
n_t = 30, n_c = 0, prior_t = prior_gamma(0.1, 1),
criterion = criterion_posterior(theta_tv = 0.15, theta_mav = 0,
gamma_go = 0.6, gamma_nogo = 0.8),
milestone = 3,
conduct = conduct_tte(accrual_time = c(0, 5, 10, 15),
accrual_rate = c(0.4, 2, 4.5),
dropout_hazard = 0.00226, cut_time = 15.44),
fixed_c = 0.72
)
des
qdm_decide(des, data_t = data_tte(events = 6, exposure = 150))
# Concurrent control
design_tte(
n_t = 30, n_c = 30, prior_t = prior_gamma(0.1, 1),
prior_c = prior_gamma(0.1, 1),
criterion = criterion_posterior(theta_tv = 0.15, theta_mav = 0,
gamma_go = 0.6, gamma_nogo = 0.8),
milestone = 3,
conduct = conduct_tte(accrual_time = c(0, 12), cut_events = 25)
)
# Hazard ratio in the randomized study of the example of Huang et al.
# (2019) (2:1 randomization, analysis at 127 events): Go if HR < 0.67
# with probability at least 0.5, NoGo if HR >= 0.8 with probability at
# least 0.6
design_tte(
n_t = 112, n_c = 56, prior_t = prior_gamma(0.01, 0.01),
prior_c = prior_gamma(0.01, 0.01),
criterion = criterion_posterior(theta_tv = 0.67, theta_mav = 0.8,
gamma_go = 0.5, gamma_nogo = 0.6,
direction = "less"),
effect = "hazard_ratio",
conduct = conduct_tte(accrual_time = c(0, 13), dropout_hazard = 0.003,
cut_events = 127)
)
Format an external data specification
Description
Format an external data specification
Usage
## S3 method for class 'qdm_borrow'
format(x, digits = 4L, ...)
Arguments
x |
An object of class |
digits |
Number of significant digits for numeric values. |
... |
Not used. |
Value
A character string describing the external data and the power prior weight.
Examples
format(borrow(data_binary(n = 20, y = 8), a0 = 0.5))
Format a decision boundary
Description
Formats the decision intervals of qdm_boundary as tables
with one row per condition and one column per decision: the range of the
observed quantity (numbers of responders or events, or observed means),
and the corresponding observed response rates (binary endpoint) or
milestone survival probabilities (time-to-event endpoint) and observed
treatment effects.
Usage
## S3 method for class 'qdm_boundary'
format(x, digits = 4L, n = 20L, ...)
Arguments
x |
An object of class |
digits |
Number of significant digits for observed means, milestone survival probabilities, effects and conditions. |
n |
Maximum number of conditions shown in each table. |
... |
Not used. |
Value
A character vector with one element per line of the tables
(print.qdm_boundary prints them). For rows subset from
the object, which no longer have its attributes, the formatted data
frame.
Examples
des <- design_binary(
n_t = 20, n_c = 0, prior_t = prior_beta(1, 1),
criterion = criterion_posterior(theta_tv = 0.2, theta_mav = 0.05,
gamma_go = 0.8, gamma_nogo = 0.8),
fixed_c = 0.2
)
format(qdm_boundary(des, n_t = c(10, 20)))
Format a calibration
Description
Format a calibration
Usage
## S3 method for class 'qdm_calibration'
format(x, digits = 4L, ...)
Arguments
x |
An object of class |
digits |
Number of significant digits for numeric values. |
... |
Not used. |
Value
A character vector with one element per line of the description (without the table of decision probabilities).
Examples
des <- design_binary(
n_t = 12, n_c = 12,
prior_t = prior_beta(0.5, 0.5), prior_c = prior_beta(0.5, 0.5),
criterion = criterion_posterior(theta_tv = 0.2, theta_mav = 0.1,
gamma_go = 0.5, gamma_nogo = 0.8)
)
format(qdm_calibrate(des, data.frame(pi_t = 0.4, pi_c = 0.4),
data.frame(pi_t = 0.7, pi_c = 0.4),
target_go = 0.05, target_nogo = 0.2))
Format the conduct of a study
Description
Format the conduct of a study
Usage
## S3 method for class 'qdm_conduct'
format(x, digits = 4L, ...)
Arguments
x |
An object of class |
digits |
Number of significant digits for numeric values. |
... |
Not used. |
Value
A character vector with one element per line of the description.
Examples
format(conduct_tte(accrual_time = c(0, 12), cut_events = 20))
Format a decision criterion
Description
Format a decision criterion
Usage
## S3 method for class 'qdm_criterion'
format(x, digits = 4L, ...)
Arguments
x |
An object of class |
digits |
Number of significant digits for numeric values. |
... |
Not used. |
Value
A character vector with one element per line of the description.
Examples
format(criterion_posterior(theta_tv = 0.2, theta_mav = 0.1,
gamma_go = 0.5, gamma_nogo = 0.8))
Format a data specification
Description
Format a data specification
Usage
## S3 method for class 'qdm_data'
format(x, digits = 4L, ...)
Arguments
x |
An object of class |
digits |
Number of significant digits for numeric values. |
... |
Not used. |
Value
A character string describing the data.
Examples
format(data_binary(n = 12, y = 7))
Format a decision
Description
Format a decision
Usage
## S3 method for class 'qdm_decision'
format(x, digits = 4L, ...)
Arguments
x |
An object of class |
digits |
Number of significant digits for numeric values. |
... |
Not used. |
Value
A character vector with one element per line of the description.
Examples
des <- design_binary(
n_t = 12, n_c = 12,
prior_t = prior_beta(0.5, 0.5), prior_c = prior_beta(0.5, 0.5),
criterion = criterion_posterior(theta_tv = 0.2, theta_mav = 0.1,
gamma_go = 0.5, gamma_nogo = 0.8)
)
format(qdm_decide(des, data_binary(12, 9), data_binary(12, 4)))
Format a design
Description
Format a design
Usage
## S3 method for class 'qdm_design'
format(x, digits = 4L, ...)
Arguments
x |
An object of class |
digits |
Number of significant digits for numeric values. |
... |
Not used. |
Value
A character vector with one element per line of the description.
Examples
des <- design_binary(
n_t = 12, n_c = 12,
prior_t = prior_beta(0.5, 0.5), prior_c = prior_beta(0.5, 0.5),
criterion = criterion_posterior(theta_tv = 0.2, theta_mav = 0.1,
gamma_go = 0.5, gamma_nogo = 0.8)
)
format(des)
Format a hypothetical control specification
Description
Format a hypothetical control specification
Usage
## S3 method for class 'qdm_hypothetical'
format(x, digits = 4L, ...)
Arguments
x |
An object of class |
digits |
Number of significant digits for numeric values. |
... |
Not used. |
Value
A character string describing the hypothetical control.
Examples
format(hypothetical(mean = 1, r = 1))
Format a search for the sample size
Description
Format a search for the sample size
Usage
## S3 method for class 'qdm_n_search'
format(x, digits = 4L, ...)
Arguments
x |
An object of class |
digits |
Number of significant digits. |
... |
Not used. |
Value
A character vector of lines.
Examples
des <- design_binary(
n_t = 12, n_c = 12,
prior_t = prior_beta(0.5, 0.5), prior_c = prior_beta(0.5, 0.5),
criterion = criterion_posterior(theta_tv = 0.2, theta_mav = 0.1,
gamma_go = 0.5, gamma_nogo = 0.8)
)
res <- qdm_find_n(des, data.frame(pi_t = 0.4, pi_c = 0.4),
data.frame(pi_t = 0.7, pi_c = 0.4), target_go = 0.1,
target_nogo = 0.1, n_t = seq(6, 20, by = 2))
format(res)
Format a prior specification
Description
Format a prior specification
Usage
## S3 method for class 'qdm_prior'
format(x, digits = 4L, ...)
Arguments
x |
An object of class |
digits |
Number of significant digits for numeric values. |
... |
Not used. |
Value
A character string describing the prior distribution.
Examples
format(prior_beta(0.5, 0.5))
Format a design specification
Description
Format a design specification
Usage
## S3 method for class 'qdm_spec'
format(x, digits = 4L, ...)
Arguments
x |
An object of class |
digits |
Number of significant digits for numeric values. |
... |
Not used. |
Value
A character vector with one element per line of the description.
For a specification that is not complete, it lists the arguments set and
those still needed. For a complete specification, it gives the
description of the design that qdm_build creates (see
format.qdm_design), or the error that building it gives.
Examples
spec <- qdm_endpoint("binary") |>
qdm_sample_size(n_t = 12, n_c = 12)
format(spec)
Hypothetical control for an uncontrolled study
Description
Specifies the distribution of a hypothetical control group, used when the proof-of-concept study has no concurrent control group (Kang et al., 2026).
Usage
hypothetical(data = NULL, mean = NULL, r = NULL)
Arguments
data |
Hypothetical control data created by
|
mean |
Location of the hypothetical control mean, a number for one continuous endpoint or a numeric vector of length 2 for two continuous endpoints. |
r |
Positive ratio of the squared scale of the hypothetical control to that of the treatment group (continuous endpoints). |
Details
For binary and time-to-event endpoints, give data: the
hypothetical control data are combined with the prior of the control
group, for example \pi_c \sim \textrm{Beta}(a_c + y, b_c + n - y)
for one binary endpoint, or a Gamma distribution of the hazard with shape
a_c + d and rate b_c + E for d events in the total
observed time E. For continuous endpoints, give mean and r: the
control mean has the same t distribution as the posterior distribution of
the treatment mean, with location mean and squared scale multiplied
by r, that is
\mu_c \sim t_{\nu_{nt}}(\mu_{0c}, r \sigma_{nt}^2 / \kappa_{nt}).
Value
An object of class "qdm_hypothetical" with elements
type ("data" or "location"), data,
mean and r.
References
Kang, R., Yamaguchi, Y. and Han, C. (2026). Bayesian quantitative decision-making framework in cell and gene therapy development for rare diseases. Journal of Biopharmaceutical Statistics. doi:10.1080/10543406.2026.2655410
Examples
# Binary endpoint: 5 responders out of 15 hypothetical control subjects
hypothetical(data = data_binary(n = 15, y = 5))
# Continuous endpoint: control mean located at 1 with the same scale
hypothetical(mean = 1, r = 1)
# Time-to-event endpoint: 8 events in a total observed time of 60
hypothetical(data = data_tte(events = 8, exposure = 60))
Distribution function of the difference of two Beta-binomial proportions
Description
Computes \Pr(Y_t / m_t - Y_c / m_c \le q) (or the upper tail
\Pr(Y_t / m_t - Y_c / m_c > q)) for independent
Y_t \sim \textrm{Beta-binomial}(m_t, a_t, b_t) and
Y_c \sim \textrm{Beta-binomial}(m_c, a_c, b_c). This is the posterior
predictive probability for the difference in response proportions of a
future study with m_t and m_c subjects.
Usage
pbetabinomdiff(q, m_t, a_t, b_t, m_c, a_c, b_c, lower.tail = TRUE)
Arguments
q |
Numeric vector of quantiles. |
m_t, m_c |
Numbers of future subjects in the treatment and control groups (whole numbers of at least 1). |
a_t, b_t |
Positive shape parameters of the treatment group. |
a_c, b_c |
Positive shape parameters of the control group. |
lower.tail |
Logical; if |
Details
The probability is an exact finite sum. The probability mass functions are
computed on the log scale, so large values of m_t and m_c do not
cause overflow. Each difference is compared with q after a single
division of the exact integer numerator m_c Y_t - m_t Y_c by
m_t m_c, so differences that are mathematically equal to a decimal
q are classified correctly (they belong to the lower tail).
Value
A numeric vector of probabilities. The arguments q,
a_t, b_t, a_c and b_c are recycled to a common
length; each must have length 1 or the common length.
See Also
Other distributions:
cellprob_binary2(),
pbetadiff(),
phazardratio(),
psurvdiff(),
ptdiff(),
rdirichlet()
Examples
# Predictive probability that the future difference exceeds 0, with
# Jeffreys priors, 7/12 versus 4/12 responders and 20 future subjects per
# group
pbetabinomdiff(0, m_t = 20, a_t = 7.5, b_t = 5.5, m_c = 20, a_c = 4.5,
b_c = 8.5, lower.tail = FALSE)
Distribution function of the difference of two Beta variables
Description
Computes \Pr(\pi_t - \pi_c \le q) (or the upper tail
\Pr(\pi_t - \pi_c > q)) for independent
\pi_t \sim \textrm{Beta}(a_t, b_t) and
\pi_c \sim \textrm{Beta}(a_c, b_c). This is the posterior probability
used for a single binary endpoint.
Usage
pbetadiff(q, a_t, b_t, a_c, b_c, lower.tail = TRUE)
Arguments
q |
Numeric vector of quantiles. |
a_t, b_t |
Positive shape parameters of the treatment group. |
a_c, b_c |
Positive shape parameters of the control group. |
lower.tail |
Logical; if |
Details
The upper tail is computed as
\Pr(\pi_t - \pi_c > q) = \Pr(\pi_c < -q) +
\int f_c(x) \Pr(\pi_t > x + q) \, dx,
where the integral runs over the values of x with
0 \le x + q \le 1, and the first term is zero for
q \ge 0. The integral is evaluated by adaptive Gauss-Kronrod
quadrature (the QUADPACK routine used by integrate),
with the range split at quantiles of both Beta distributions so that
concentrated distributions are integrated accurately. When the density of
\pi_c is unbounded at 0 (a_c < 1) or at 1 (b_c < 1), the
integral on that side of the median of \pi_c is evaluated in the
variable s = x^{a_c} or s = (1 - x)^{b_c}, in which the
integrand is bounded. The lower tail is
computed directly from the same formula with the roles of the two groups
exchanged, so both tails are accurate near 0.
Value
A numeric vector of probabilities. All arguments except
lower.tail are recycled to a common length; each must have length
1 or the common length.
See Also
Other distributions:
cellprob_binary2(),
pbetabinomdiff(),
phazardratio(),
psurvdiff(),
ptdiff(),
rdirichlet()
Examples
# Posterior probability that the response rate difference exceeds 0.1,
# with Jeffreys priors and 7/12 versus 4/12 responders
pbetadiff(0.1, a_t = 7.5, b_t = 5.5, a_c = 4.5, b_c = 8.5,
lower.tail = FALSE)
Distribution function of the ratio of two hazards
Description
Computes \Pr(\lambda_t / \lambda_c \le q) (or the upper tail
\Pr(\lambda_t / \lambda_c > q)) for hazards with independent Gamma
distributions, \lambda_t \sim \textrm{Gamma}(a_t, b_t) and
\lambda_c \sim \textrm{Gamma}(a_c, b_c) (shape and rate). This is the
posterior probability used for a time-to-event endpoint evaluated by the
hazard ratio with a concurrent, external or hypothetical control.
Usage
phazardratio(q, shape_t, rate_t, shape_c, rate_c, lower.tail = TRUE)
Arguments
q |
Numeric vector of quantiles (hazard ratios). |
shape_t, rate_t |
Positive shape and rate of the treatment hazard. |
shape_c, rate_c |
Positive shape and rate of the control hazard. |
lower.tail |
Logical; if |
Details
Because 2 b_k \lambda_k has the chi-squared distribution with
2 a_k degrees of freedom, (b_t \lambda_t / a_t) /
(b_c \lambda_c / a_c) has the F distribution with 2 a_t and
2 a_c degrees of freedom, and
\Pr(\lambda_t / \lambda_c \le q) =
F_{2 a_t, 2 a_c}\left(\frac{q \, a_c \, b_t}{a_t \, b_c}\right),
which is computed exactly by pf.
Value
A numeric vector of probabilities. All arguments except
lower.tail are recycled to a common length; each must have length
1 or the common length.
See Also
Other distributions:
cellprob_binary2(),
pbetabinomdiff(),
pbetadiff(),
psurvdiff(),
ptdiff(),
rdirichlet()
Examples
# Posterior probability that the hazard ratio is below 0.7 with 20 events
# in 300 months of follow-up versus 30 events in 250 months (Gamma(0.1, 1)
# priors)
phazardratio(0.7, shape_t = 20.1, rate_t = 301, shape_c = 30.1,
rate_c = 251)
Plot a decision boundary
Description
Draws the decision intervals computed by qdm_boundary as
regions filled by the decision (Go, NoGo, Gray, or Miss if it occurs):
the horizontal axis is the condition (for example, the number of control
responders or the treatment group size) and the vertical axis is the
observed quantity (numbers of responders or events, or the observed
treatment mean) or, for continuous endpoints with a concurrent control
group, the observed difference in means. The boundary values are
written on the Go and NoGo regions next to the boundaries, for example
the smallest number of responders that leads to a Go decision. With a
concurrent control group and a binary endpoint, the observed response
rate of the treatment group is shown on a secondary axis.
Usage
## S3 method for class 'qdm_boundary'
plot(
x,
col_go = "#658D1B",
col_nogo = "#D91E49",
col_gray = "#939597",
col_miss = "#E69F00",
labels = TRUE,
label_size = NULL,
base_size = 11,
legend_position = "bottom",
...
)
Arguments
x |
An object of class |
col_go, col_nogo, col_gray, col_miss |
Colors of the Go, NoGo, Gray and Miss decisions: color names or hexadecimal codes. The defaults are green, red, gray and orange. Transparency (an alpha value in the code) is not used in the heat maps. |
labels |
|
label_size |
Size of the boundary values, in millimeters, or
|
base_size |
Base font size of |
legend_position |
Position of the legend: |
... |
Not used; arguments given here are ignored with a warning. |
Details
The plot is a ggplot object, so it can be changed further by adding
ggplot2 functions, for example ggplot2::labs(),
ggplot2::theme() and ggplot2::scale_fill_manual().
Value
A ggplot object.
Examples
des <- design_binary(
n_t = 12, n_c = 12,
prior_t = prior_beta(0.5, 0.5), prior_c = prior_beta(0.5, 0.5),
criterion = criterion_posterior(theta_tv = 0.2, theta_mav = 0.1,
gamma_go = 0.5, gamma_nogo = 0.8)
)
b <- qdm_boundary(des)
plot(b)
plot(b, labels = c(0, 4, 8), col_gray = "gray80", base_size = 14,
legend_position = "right")
Plot a calibration
Description
Draws the probability that the Go criterion is met under
scenario_go and the probability that the NoGo criterion is met under
scenario_nogo against the threshold, with the targets (horizontal
lines) and the chosen thresholds (vertical lines).
scenario_go is a scenario under which a Go decision would be wrong
and scenario_nogo one under which a NoGo decision would be wrong,
so the legend calls the two probabilities those of a false Go and a false
NoGo.
Usage
## S3 method for class 'qdm_calibration'
plot(
x,
col_go = "#658D1B",
col_nogo = "#D91E49",
linewidth = 1,
base_size = 11,
legend_position = "bottom",
...
)
Arguments
x |
An object of class |
col_go, col_nogo |
Colors of the curves, targets and thresholds of the Go and NoGo criteria: color names or hexadecimal codes. The defaults are green and red. |
linewidth |
Width of the calibration curves, in the units of the
|
base_size |
Base font size of |
legend_position |
Position of the legend: |
... |
Not used; arguments given here are ignored with a warning. |
Details
The plot is a ggplot object, so it can be changed further by adding
ggplot2 functions, for example ggplot2::labs() and
ggplot2::theme().
Value
A ggplot object.
Examples
des <- design_binary(
n_t = 12, n_c = 12,
prior_t = prior_beta(0.5, 0.5), prior_c = prior_beta(0.5, 0.5),
criterion = criterion_posterior(theta_tv = 0.2, theta_mav = 0.1,
gamma_go = 0.5, gamma_nogo = 0.8)
)
cal <- qdm_calibrate(des, data.frame(pi_t = 0.4, pi_c = 0.4),
data.frame(pi_t = 0.7, pi_c = 0.4),
target_go = 0.05, target_nogo = 0.2)
plot(cal)
plot(cal, linewidth = 0.6, base_size = 14, legend_position = "top")
Plot the operating characteristics of several designs
Description
For one endpoint, draws one panel per decision with the probability of
that decision against the true treatment effect (or the parameter of the
treatment group without a concurrent control group, as in
plot.qdm_oc), with one curve per design. For two endpoints,
draws heat maps of the probabilities, with one row of panels per design
and one column per decision.
Usage
## S3 method for class 'qdm_comparison'
plot(
x,
decisions = NULL,
col_design = NULL,
col_go = "#658D1B",
col_nogo = "#D91E49",
col_gray = "#939597",
col_miss = "#E69F00",
linewidth = 1,
point_size = 1.5,
label_size = NULL,
base_size = 11,
legend_position = "bottom",
cell_values = TRUE,
...
)
Arguments
x |
An object of class |
decisions |
The decisions to draw, some of |
col_design |
Colors of the curves of the designs (one endpoint), one
per design, or |
col_go, col_nogo, col_gray, col_miss |
Colors of the heat maps of the decisions (two endpoints). |
linewidth, point_size, label_size, base_size, legend_position |
As in
|
cell_values |
Two endpoints only: |
... |
Not used; arguments given here are ignored with a warning. |
Details
The horizontal axis must be the same for all designs: the scenarios are
the same, but a design without a concurrent control group has the
parameter of the treatment group on the axis, and the thresholds are
shifted by the location of the control group (see
plot.qdm_oc). The thresholds of the criteria are drawn when
they are the same for all designs.
Value
A ggplot object.
Examples
des <- design_binary(
n_t = 12, n_c = 12,
prior_t = prior_beta(0.5, 0.5), prior_c = prior_beta(0.5, 0.5),
criterion = criterion_posterior(theta_tv = 0.2, theta_mav = 0.1,
gamma_go = 0.5, gamma_nogo = 0.8)
)
cmp <- qdm_compare(list(n12 = des, n24 = qdm_sample_size(des, 24, 24)),
data.frame(pi_t = seq(0.2, 0.8, by = 0.1), pi_c = 0.3))
plot(cmp)
plot(cmp, decisions = "Go")
Plot a decision
Description
Shows how the observed data lead to the decision, for example to explain a decision to a clinical team.
Usage
## S3 method for class 'qdm_decision'
plot(
x,
col_go = "#658D1B",
col_nogo = "#D91E49",
col_gray = "#939597",
linewidth = 1,
label_size = NULL,
base_size = 11,
legend_position = "bottom",
...
)
Arguments
x |
An object of class |
col_go, col_nogo, col_gray |
Colors of the Go region, the NoGo region and the other regions. |
linewidth |
Width of the density curve, in the units of the
|
label_size |
Size of the text drawn in the plot, in millimeters, or
|
base_size |
Base font size of |
legend_position |
Position of the legend: |
... |
Not used; arguments given here are ignored with a warning. |
Details
For one endpoint and a criterion based on posterior probability, the plot
shows the posterior density of the treatment effect \theta, with
the target value and the minimum acceptable value (dotted lines) and the
Go and NoGo regions shaded; the subtitle gives the posterior
probabilities of the regions, their thresholds and whether the criteria
are met. The horizontal axis is the treatment effect for every control
group (for a fixed control, \theta is the parameter of the
treatment group minus the fixed value). The density is computed from the
exact distribution function of the effect (numerical integration for a
continuous endpoint, whatever the method of the design), on a grid that
contains the thresholds and covers the central 99.9 percent of the
distribution and the thresholds; the probabilities in the subtitle are
those of the decision, computed by the method of the design.
For one endpoint and a criterion based on posterior predictive probability, the plot shows the predictive probabilities of the Go and NoGo regions as bars, with their thresholds (horizontal segments).
For two endpoints, the plot shows the regions of the plane of the two
effects (see qdm_regions; for a predictive criterion, the
effects observed in the future study, marked "future" in the labels of the
axes), with the favorable side of each endpoint at the right and at the
top, and the posterior (or predictive) probability of each region; the
shade of each region grows with its probability. With
rule = "joint", the regions of the Go and NoGo
criteria have the colors of these decisions.
Value
A ggplot object.
Examples
des <- design_binary(
n_t = 12, n_c = 12,
prior_t = prior_beta(0.5, 0.5), prior_c = prior_beta(0.5, 0.5),
criterion = criterion_posterior(theta_tv = 0.2, theta_mav = 0.1,
gamma_go = 0.5, gamma_nogo = 0.8)
)
dec <- qdm_decide(des, data_t = data_binary(12, 9),
data_c = data_binary(12, 4))
plot(dec)
# Two continuous endpoints
des2 <- design_continuous2(
n_t = 12, n_c = 12, prior_t = prior_vague(), prior_c = prior_vague(),
criterion = criterion_posterior(theta_tv = c(10, 2), theta_mav = c(5, 1),
gamma_go = 0.5, gamma_nogo = 0.3)
)
vc <- function(s1, s2, r) matrix(c(s1^2, r * s1 * s2, r * s1 * s2, s2^2), 2)
dec2 <- qdm_decide(
des2,
data_t = data_continuous2(12, c(18, 2.5), vc(60, 5, 0.4)),
data_c = data_continuous2(12, c(-10, -1), vc(70, 6, 0.2))
)
plot(dec2)
Plot a search for the sample size
Description
Draws the probabilities that the Go criterion is met under
scenario_go and that the NoGo criterion is met under
scenario_nogo against the number of subjects in the treatment
group, with the targets (dashed lines, one gray line when the two targets
are equal) and the smallest candidate that meets them (dotted line). The
vertical axis runs from 0 to the largest probability or target, so that
small probabilities can be read.
scenario_go is a scenario under which a Go decision would be wrong
and scenario_nogo one under which a NoGo decision would be wrong,
so the legend calls the two probabilities those of a false Go and a false
NoGo.
Usage
## S3 method for class 'qdm_n_search'
plot(
x,
col_go = "#658D1B",
col_nogo = "#D91E49",
linewidth = 1,
point_size = 1.5,
base_size = 11,
legend_position = "bottom",
...
)
Arguments
x |
An object of class |
col_go, col_nogo |
Colors of the probabilities and targets of the Go and NoGo criteria. |
linewidth |
Width of the lines, in the units of the |
point_size |
Size of the points, in millimeters. |
base_size |
Base font size of |
legend_position |
Position of the legend: |
... |
Not used; arguments given here are ignored with a warning. |
Value
A ggplot object.
Examples
des <- design_binary(
n_t = 12, n_c = 12,
prior_t = prior_beta(0.5, 0.5), prior_c = prior_beta(0.5, 0.5),
criterion = criterion_posterior(theta_tv = 0.2, theta_mav = 0.1,
gamma_go = 0.5, gamma_nogo = 0.8)
)
res <- qdm_find_n(des, data.frame(pi_t = 0.4, pi_c = 0.4),
data.frame(pi_t = 0.7, pi_c = 0.4), target_go = 0.1,
target_nogo = 0.1, n_t = seq(6, 30, by = 2))
plot(res)
Plot operating characteristics
Description
Draws the probabilities of Go, NoGo and Gray decisions (and Miss decisions
if they have positive probability) against the true treatment effect of
the scenarios. For a time-to-event endpoint evaluated by the milestone
survival, the effect is the difference of the milestone survival
probabilities \exp(-\log(2) t_0 / m) given by the median survival
times m of the scenarios; evaluated by the hazard ratio, it is the
hazard ratio m_c / m_t of the median survival times. For a design
without a concurrent control group, the horizontal axis is the true
response rate (binary endpoint), mean (continuous endpoint) or milestone
survival probability (time-to-event endpoint evaluated by the milestone
survival) of the treatment group, and the thresholds of the criterion are
shifted by the fixed control value, or otherwise by the mean (binary and
time-to-event) or location (continuous) of the distribution of the control
group; for the hazard ratio, the axis is the ratio of the treatment hazard
\log(2) / m_t to the fixed control hazard or to the mean of the
distribution of the control hazard, and the thresholds are not shifted. The
scenarios must have distinct values on the horizontal axis, so scenarios
with the same effect (for example, with several standard deviations or
control parameters) are plotted separately.
Usage
## S3 method for class 'qdm_oc'
plot(
x,
col_go = "#658D1B",
col_nogo = "#D91E49",
col_gray = "#939597",
col_miss = "#E69F00",
linewidth = 1,
point_size = 1.5,
label_size = NULL,
base_size = 11,
legend_position = "bottom",
overlay = FALSE,
cell_values = TRUE,
...
)
Arguments
x |
An object of class |
col_go, col_nogo, col_gray, col_miss |
Colors of the Go, NoGo, Gray and Miss decisions: color names or hexadecimal codes. The defaults are green, red, gray and orange. Transparency (an alpha value in the code) is not used in the heat maps. |
linewidth |
Width of the curves, in the units of the |
point_size |
Size of the points, in millimeters. |
label_size |
Size of the text drawn in the plot, in millimeters: the
labels of the thresholds, or the probabilities in the cells of the heat
maps. |
base_size |
Base font size of |
legend_position |
Position of the legend: |
overlay |
Two endpoints only: |
cell_values |
Two endpoints only: |
... |
Not used; arguments given here are ignored with a warning. |
Details
For two endpoints, the plot has one heat map per decision, with the true
treatment effects of the two endpoints (or the true parameters of the
treatment group without a concurrent control group) on the axes and the
probability of the decision in each cell; scenarios that are not evaluable
are marked "NE". The scenarios must have distinct values on the axes, so
scenarios with several correlations (or several parameters of the control
group) are plotted separately. Each panel is shaded from white
(probability 0) to the color of its decision (probability 1); the heat maps
have no legend. With overlay = TRUE, a single heat map is drawn
instead: each cell has the color of the decision with the highest
probability (Go, Gray or NoGo, or Miss if it occurs; ties go to the first
in this order), shaded in five steps of that probability (below 0.5, 0.5
to 0.6, 0.6 to 0.7, 0.7 to 0.8, and 0.8 or more), with legends for the
decisions and the steps (shown in gray whatever the colors of the
decisions), as in the heat maps of Yamaguchi et al. (submitted,
Figure 2).
The plot is a ggplot object, so it can be changed further by adding
ggplot2 functions, for example ggplot2::labs() for the title
and the axis labels, ggplot2::theme() for the text and the legend,
and ggplot2::scale_colour_manual() or
ggplot2::scale_linetype_manual() for the curves of one endpoint.
The colors of the heat maps are set by the color arguments.
Value
A ggplot object.
References
Yamaguchi, Y., Hu, H., Huang, Y., Han, C., Homma, G. and Wang, A. (submitted). Bivariate Bayesian quantitative decision-making for two endpoints in rare disease drug development.
Examples
des <- design_binary(
n_t = 12, n_c = 12,
prior_t = prior_beta(0.5, 0.5), prior_c = prior_beta(0.5, 0.5),
criterion = criterion_posterior(theta_tv = 0.2, theta_mav = 0.1,
gamma_go = 0.5, gamma_nogo = 0.8)
)
oc <- qdm_oc(des, data.frame(pi_t = seq(0.2, 0.9, by = 0.05), pi_c = 0.4))
plot(oc)
# Other colors, thinner lines, larger text and the legend on the right,
# with a title added by ggplot2
plot(oc, col_go = "darkgreen", col_nogo = "firebrick", linewidth = 0.6,
base_size = 14, legend_position = "right") +
ggplot2::labs(title = "Operating characteristics")
# Two binary endpoints: one heat map per decision, or a single heat map
# of the decision with the highest probability in each cell
prior <- prior_dirichlet(rep(0.25, 4))
des2 <- design_binary2(
n_t = 6, n_c = 6, prior_t = prior, prior_c = prior,
criterion = criterion_posterior(theta_tv = c(0.15, 0.15),
theta_mav = c(0.1, 0.1),
gamma_go = 0.6, gamma_nogo = 0.6),
nMC = 500
)
eff <- expand.grid(theta1 = c(0, 0.2, 0.4), theta2 = c(0, 0.2, 0.4))
oc2 <- qdm_oc(des2, data.frame(pi_t1 = 0.2 + eff$theta1,
pi_t2 = 0.2 + eff$theta2, rho_t = 0.3,
pi_c1 = 0.2, pi_c2 = 0.2, rho_c = 0.3),
seed = 1)
plot(oc2)
plot(oc2, overlay = TRUE)
plot(oc2, overlay = TRUE, cell_values = FALSE)
Print an external data specification
Description
Print an external data specification
Usage
## S3 method for class 'qdm_borrow'
print(x, ...)
Arguments
x |
An object of class |
... |
Passed to |
Value
x, invisibly.
Examples
print(borrow(data_binary(n = 20, y = 8), a0 = 0.5))
Print a decision boundary
Description
Prints the decision intervals of qdm_boundary as up to
three tables, each with one row per condition (for example, the number of
control responders or the treatment group size) and one column per
decision. The first table gives the range of the observed quantity
(numbers of responders or events, or observed means), the second the
corresponding observed response rates or milestone survival
probabilities, and the last the observed treatment effects. For example,
the entry "10-20" in the column Go means that 10 to 20
responders lead to a Go decision. The object itself
is a data frame with one row per interval (see qdm_boundary).
Usage
## S3 method for class 'qdm_boundary'
print(x, digits = 4L, n = 20L, ...)
Arguments
x |
An object of class |
digits |
Number of significant digits for observed means, milestone survival probabilities, effects and conditions. |
n |
Maximum number of conditions shown in each table. |
... |
Not used. |
Value
x, invisibly.
Examples
des <- design_binary(
n_t = 12, n_c = 12,
prior_t = prior_beta(0.5, 0.5), prior_c = prior_beta(0.5, 0.5),
criterion = criterion_posterior(theta_tv = 0.2, theta_mav = 0.1,
gamma_go = 0.5, gamma_nogo = 0.8)
)
b <- qdm_boundary(des)
print(b, n = 5)
# The intervals as a data frame
head(as.data.frame(b))
Print a calibration
Description
Prints the chosen thresholds and the decision probabilities of the design with these thresholds under the two scenarios.
Usage
## S3 method for class 'qdm_calibration'
print(x, digits = 4L, ...)
Arguments
x |
An object of class |
digits |
Number of significant digits for numeric values. |
... |
Not used. |
Value
x, invisibly.
Examples
des <- design_binary(
n_t = 12, n_c = 12,
prior_t = prior_beta(0.5, 0.5), prior_c = prior_beta(0.5, 0.5),
criterion = criterion_posterior(theta_tv = 0.2, theta_mav = 0.1,
gamma_go = 0.5, gamma_nogo = 0.8)
)
print(qdm_calibrate(des, data.frame(pi_t = 0.4, pi_c = 0.4),
data.frame(pi_t = 0.7, pi_c = 0.4),
target_go = 0.05, target_nogo = 0.2))
Print R code
Description
Print R code
Usage
## S3 method for class 'qdm_code'
print(x, ...)
Arguments
x |
An object of class |
... |
Not used. |
Value
x, invisibly.
Examples
des <- design_binary(
n_t = 12, n_c = 12,
prior_t = prior_beta(0.5, 0.5), prior_c = prior_beta(0.5, 0.5),
criterion = criterion_posterior(theta_tv = 0.2, theta_mav = 0.1,
gamma_go = 0.5, gamma_nogo = 0.8)
)
print(show_code(des))
Print the operating characteristics of several designs
Description
Print the operating characteristics of several designs
Usage
## S3 method for class 'qdm_comparison'
print(x, digits = 4L, ...)
Arguments
x |
An object of class |
digits |
Number of significant digits of the probabilities. |
... |
Not used. |
Value
x, invisibly.
Examples
des <- design_binary(
n_t = 12, n_c = 12,
prior_t = prior_beta(0.5, 0.5), prior_c = prior_beta(0.5, 0.5),
criterion = criterion_posterior(theta_tv = 0.2, theta_mav = 0.1,
gamma_go = 0.5, gamma_nogo = 0.8)
)
qdm_compare(list(n12 = des, n24 = qdm_sample_size(des, 24, 24)),
data.frame(pi_t = c(0.3, 0.6), pi_c = 0.3))
Print the conduct of a study
Description
Print the conduct of a study
Usage
## S3 method for class 'qdm_conduct'
print(x, ...)
Arguments
x |
An object of class |
... |
Passed to |
Value
x, invisibly.
Examples
conduct_tte(accrual_time = c(0, 12), cut_events = 20)
Print a decision criterion
Description
Print a decision criterion
Usage
## S3 method for class 'qdm_criterion'
print(x, ...)
Arguments
x |
An object of class |
... |
Passed to |
Value
x, invisibly.
Examples
print(criterion_predictive(theta_null = 0, m_t = 50, gamma_go = 0.9,
gamma_nogo = 0.7))
Print a data specification
Description
Print a data specification
Usage
## S3 method for class 'qdm_data'
print(x, ...)
Arguments
x |
An object of class |
... |
Passed to |
Value
x, invisibly.
Examples
print(data_continuous(n = 12, mean = 3.2, sd = 2))
Print a decision
Description
Print a decision
Usage
## S3 method for class 'qdm_decision'
print(x, ...)
Arguments
x |
An object of class |
... |
Passed to |
Value
x, invisibly.
Examples
des <- design_binary(
n_t = 12, n_c = 12,
prior_t = prior_beta(0.5, 0.5), prior_c = prior_beta(0.5, 0.5),
criterion = criterion_predictive(theta_null = 0, m_t = 50,
gamma_go = 0.9, gamma_nogo = 0.7)
)
print(qdm_decide(des, data_binary(12, 9), data_binary(12, 4)))
Print a design
Description
Print a design
Usage
## S3 method for class 'qdm_design'
print(x, ...)
Arguments
x |
An object of class |
... |
Passed to |
Value
x, invisibly.
Examples
des <- design_binary(
n_t = 12, n_c = 0,
prior_t = prior_beta(0.5, 0.5), prior_c = prior_beta(0.5, 0.5),
criterion = criterion_posterior(theta_tv = 0.2, theta_mav = 0.1,
gamma_go = 0.5, gamma_nogo = 0.8),
hypothetical_c = hypothetical(data = data_binary(n = 12, y = 4))
)
print(des)
Print a hypothetical control specification
Description
Print a hypothetical control specification
Usage
## S3 method for class 'qdm_hypothetical'
print(x, ...)
Arguments
x |
An object of class |
... |
Passed to |
Value
x, invisibly.
Examples
print(hypothetical(data = data_binary(n = 15, y = 5)))
Print a search for the sample size
Description
Print a search for the sample size
Usage
## S3 method for class 'qdm_n_search'
print(x, digits = 4L, ...)
Arguments
x |
An object of class |
digits |
Number of significant digits. |
... |
Not used. |
Value
x, invisibly.
Examples
des <- design_binary(
n_t = 12, n_c = 12,
prior_t = prior_beta(0.5, 0.5), prior_c = prior_beta(0.5, 0.5),
criterion = criterion_posterior(theta_tv = 0.2, theta_mav = 0.1,
gamma_go = 0.5, gamma_nogo = 0.8)
)
qdm_find_n(des, data.frame(pi_t = 0.4, pi_c = 0.4),
data.frame(pi_t = 0.7, pi_c = 0.4), target_go = 0.1,
target_nogo = 0.1, n_t = seq(6, 20, by = 2))
Print operating characteristics
Description
Print operating characteristics
Usage
## S3 method for class 'qdm_oc'
print(x, digits = 4L, ...)
Arguments
x |
An object of class |
digits |
Number of significant digits for the probabilities. |
... |
Not used. |
Value
x, invisibly.
Examples
des <- design_binary(
n_t = 12, n_c = 12,
prior_t = prior_beta(0.5, 0.5), prior_c = prior_beta(0.5, 0.5),
criterion = criterion_posterior(theta_tv = 0.2, theta_mav = 0.1,
gamma_go = 0.5, gamma_nogo = 0.8)
)
print(qdm_oc(des, data.frame(pi_t = c(0.4, 0.6), pi_c = 0.4)))
Print a prior specification
Description
Print a prior specification
Usage
## S3 method for class 'qdm_prior'
print(x, ...)
Arguments
x |
An object of class |
... |
Passed to |
Value
x, invisibly.
Examples
print(prior_nix(mu0 = 0, kappa0 = 1, nu0 = 3, sigma0 = 2))
Print a design specification
Description
Print a design specification
Usage
## S3 method for class 'qdm_spec'
print(x, ...)
Arguments
x |
An object of class |
... |
Passed to |
Value
x, invisibly.
Examples
qdm_endpoint("binary") |>
qdm_sample_size(n_t = 12, n_c = 12) |>
print()
Beta prior for a response rate
Description
Creates a Beta prior distribution for the response rate of one group in an analysis of a single binary endpoint.
Usage
prior_beta(a, b)
Arguments
a, b |
Positive shape parameters. |
Value
An object of class c("qdm_prior_beta", "qdm_prior") with
elements a and b.
See Also
Other priors:
prior_dirichlet(),
prior_gamma(),
prior_niw(),
prior_nix(),
prior_vague()
Examples
prior_beta(0.5, 0.5)
Dirichlet prior for two binary endpoints
Description
Creates a Dirichlet prior distribution for the four joint response probabilities of two binary endpoints in one group.
Usage
prior_dirichlet(alpha)
Arguments
alpha |
A numeric vector of four positive concentration parameters in
the cell order |
Details
The four cells are ordered as "00", "01", "10" and
"11", where the first digit is the response on endpoint 1 and the
second digit is the response on endpoint 2 (1 = response, 0 = no
response). The marginal response rates are therefore
\pi_1 = p_{10} + p_{11} and \pi_2 = p_{01} + p_{11}.
With alpha = rep(0.25, 4), each marginal response rate has a
Beta(0.5, 0.5) prior distribution.
Value
An object of class c("qdm_prior_dirichlet", "qdm_prior")
with element alpha, a named numeric vector of length 4.
See Also
Other priors:
prior_beta(),
prior_gamma(),
prior_niw(),
prior_nix(),
prior_vague()
Examples
prior_dirichlet(rep(0.25, 4))
Gamma prior for a hazard rate
Description
Creates a Gamma prior distribution for the hazard rate \lambda of
one group in an analysis of a time-to-event endpoint with exponential
event times. The milestone survival probability at time t_0 is
S(t_0) = \exp(-\lambda t_0).
Usage
prior_gamma(shape, rate)
Arguments
shape, rate |
Positive shape and rate parameters (the prior mean of
the hazard is |
Details
The prior is equivalent to shape events observed during a total
observed time of rate, so small values give a weakly informative
prior: prior_gamma(0.1, 1) carries the information of a tenth of an
event.
Value
An object of class c("qdm_prior_gamma", "qdm_prior") with
elements shape and rate.
See Also
Other priors:
prior_beta(),
prior_dirichlet(),
prior_niw(),
prior_nix(),
prior_vague()
Examples
prior_gamma(0.1, 1)
Normal-Inverse-Wishart prior for two continuous endpoints
Description
Creates the conjugate Normal-Inverse-Wishart prior for the mean vector
\mu and covariance matrix \Sigma of a bivariate normal endpoint
in one group:
\mu \mid \Sigma \sim N_2(\mu_0, \Sigma / \kappa_0), \quad
\Sigma \sim \textrm{Inv-Wishart}(\nu_0, \Lambda_0).
Usage
prior_niw(mu0, kappa0, nu0, Lambda0)
Arguments
mu0 |
Numeric vector of length 2, the prior mean of |
kappa0 |
Positive prior sample size for |
nu0 |
Prior degrees of freedom of the inverse Wishart distribution; must be greater than 1. |
Lambda0 |
A 2 x 2 symmetric positive definite scale matrix. |
Value
An object of class c("qdm_prior_niw", "qdm_prior") with
elements mu0, kappa0, nu0 and Lambda0.
See Also
Other priors:
prior_beta(),
prior_dirichlet(),
prior_gamma(),
prior_nix(),
prior_vague()
Examples
prior_niw(mu0 = c(0, 0), kappa0 = 1, nu0 = 4, Lambda0 = diag(2))
Normal-Inverse-chi-squared prior for a continuous endpoint
Description
Creates the conjugate Normal-Inverse-chi-squared prior for the mean
\mu and variance \sigma^2 of a normally distributed endpoint in
one group:
\mu \mid \sigma^2 \sim N(\mu_0, \sigma^2 / \kappa_0), \quad
\sigma^2 \sim \textrm{Inv-}\chi^2(\nu_0, \sigma_0^2).
Usage
prior_nix(mu0, kappa0, nu0, sigma0)
Arguments
mu0 |
Prior mean of |
kappa0 |
Positive prior sample size for |
nu0 |
Positive prior degrees of freedom for |
sigma0 |
Positive prior scale of |
Value
An object of class c("qdm_prior_nix", "qdm_prior") with
elements mu0, kappa0, nu0 and sigma0.
See Also
Other priors:
prior_beta(),
prior_dirichlet(),
prior_gamma(),
prior_niw(),
prior_vague()
Examples
prior_nix(mu0 = 0, kappa0 = 1, nu0 = 3, sigma0 = 2)
Vague prior for continuous endpoints
Description
Creates the vague (reference) prior for the parameters of a normally
distributed endpoint. For one endpoint the prior density is
p(\mu, \sigma^2) \propto \sigma^{-2}; for two endpoints it is
p(\mu, \Sigma) \propto |\Sigma|^{-3/2}. With n observations the
posterior distribution of the mean is a t distribution with n - 1
degrees of freedom for one endpoint and a bivariate t distribution with
n - 2 degrees of freedom for two endpoints.
Usage
prior_vague()
Value
An object of class c("qdm_prior_vague", "qdm_prior").
See Also
Other priors:
prior_beta(),
prior_dirichlet(),
prior_gamma(),
prior_niw(),
prior_nix()
Examples
prior_vague()
Distribution function of the difference of two milestone survival probabilities
Description
Computes \Pr(S_t - S_c \le q) (or the upper tail
\Pr(S_t - S_c > q)) for the milestone survival probabilities
S_k = \exp(-\lambda_k t_0), where the hazards have independent
Gamma distributions, \lambda_t \sim \textrm{Gamma}(a_t, b_t) and
\lambda_c \sim \textrm{Gamma}(a_c, b_c) (shape and rate). This is
the posterior probability used for a time-to-event endpoint with a
concurrent, external or hypothetical control.
Usage
psurvdiff(q, milestone, shape_t, rate_t, shape_c, rate_c, lower.tail = TRUE)
Arguments
q |
Numeric vector of quantiles. |
milestone |
Positive milestone time |
shape_t, rate_t |
Positive shape and rate of the treatment hazard. |
shape_c, rate_c |
Positive shape and rate of the control hazard. |
lower.tail |
Logical; if |
Details
The upper tail is computed as
\Pr(S_t - S_c > q) = \Pr(S_c \le -q) +
\int g_c(\lambda) G_t\left(-\log(q + e^{-\lambda t_0}) / t_0\right)
\, d\lambda,
where g_c is the density of \lambda_c, G_t is the
distribution function of \lambda_t, the integral runs over the
values of \lambda with 0 < q + e^{-\lambda t_0} < 1, and the
first term is zero for q \ge 0. The integral is evaluated by
adaptive Gauss-Kronrod quadrature (the QUADPACK routine used by
integrate), with the range split at quantiles of the
control hazard and at the values that correspond to quantiles of the
treatment hazard. When the density of \lambda_c is unbounded at 0
(a_c < 1), the integral below its median is evaluated in the
variable u = \lambda^{a_c}, in which the integrand is bounded. The
lower tail is computed from the same formula with the roles of the two
groups exchanged, so both tails are accurate near 0.
Value
A numeric vector of probabilities. All arguments except
lower.tail are recycled to a common length; each must have length
1 or the common length.
See Also
Other distributions:
cellprob_binary2(),
pbetabinomdiff(),
pbetadiff(),
phazardratio(),
ptdiff(),
rdirichlet()
Examples
# Posterior probability that the 3-month survival is higher by more than
# 0.1 with 5 events in 40 months of follow-up versus 9 events in 35 months
# (Gamma(0.1, 1) priors)
psurvdiff(0.1, milestone = 3, shape_t = 5.1, rate_t = 41,
shape_c = 9.1, rate_c = 36, lower.tail = FALSE)
Distribution function of the difference of two t variables
Description
Computes \Pr(T_t - T_c \le q) (or the upper tail
\Pr(T_t - T_c > q)) for independent location-scale t variables
T_k = \mu_k + s_k X_k, where X_k follows a t distribution with
\nu_k degrees of freedom. This is the posterior (or posterior
predictive) probability used for a single continuous endpoint.
Usage
ptdiff(
q,
mu_t,
scale_t,
df_t,
mu_c,
scale_c,
df_c,
method = c("NI", "MM", "MC"),
nMC = 10000L,
lower.tail = TRUE
)
Arguments
q |
Numeric vector of quantiles. |
mu_t, scale_t, df_t |
Location, positive scale and positive degrees of freedom of the treatment group. |
mu_c, scale_c, df_c |
Location, positive scale and positive degrees of freedom of the control group. |
method |
One of |
nMC |
Number of Monte Carlo draws per element for |
lower.tail |
Logical; if |
Details
Three methods are available.
"NI"Numerical integration over the whole real line by adaptive Gauss-Kronrod quadrature (the QUADPACK routine used by
integrate). The integral is taken over the variable of the group with the smaller scale, for example\int f_c(u) \Pr(T_t > u + q) \, duwhens_c \le s_t. The range is split around the peak of the density and around the change of the other factor, and the parts far from the origin are integrated on a logarithmic scale, so that heavy tails and very different scales are handled. The absolute error is below10^{-9}in the tests, which include scale ratios from10^{-9}to10^3and degrees of freedom from 0.5 toInf."MM"The moment-matching approximation of Yamaguchi, Homma, Takeda and Maruo (submitted, Theorem 1), which replaces the difference by a single t distribution with matched second and fourth moments. It requires
\nu_t > 4and\nu_c > 4, is evaluated in closed form, and is the fastest method."MC"Monte Carlo simulation with
nMCdraws for each element, using the random number generator of R.
Degrees of freedom may be Inf (normal distributions). For the lower
tail, the upper tail of T_c - T_t at -q is computed, so both
tails are accurate near 0.
Value
A numeric vector of probabilities. All arguments from q to
df_c are recycled to a common length; each must have length 1 or
the common length.
References
Yamaguchi, Y., Homma, G., Takeda, K. and Maruo, K. (submitted). Moment-matching approximation for t-differences in clinical trials with continuous endpoints.
See Also
Other distributions:
cellprob_binary2(),
pbetabinomdiff(),
pbetadiff(),
phazardratio(),
psurvdiff(),
rdirichlet()
Examples
ptdiff(1, mu_t = 3, scale_t = 1, df_t = 15, mu_c = 1, scale_c = 1,
df_c = 15, lower.tail = FALSE)
ptdiff(1, mu_t = 3, scale_t = 1, df_t = 15, mu_c = 1, scale_c = 1,
df_c = 15, method = "MM", lower.tail = FALSE)
Decision boundary of a design
Description
Finds the observed data that lead to each decision (Go, NoGo, Gray, or
Miss) of a design: for example, how many responders out of n are
needed for a Go decision, or how large the observed difference in means
must be. Unlike the operating characteristics, the result does not depend
on the true parameters. It is a table of decision intervals of an
observed quantity (the numbers of responders or events, or an observed
mean), one set of intervals for each value of a second quantity (the
condition), together with the corresponding observed response rates,
milestone survival probabilities and treatment effects. The intervals are
printed as tables (print.qdm_boundary) and drawn as the
regions of the decisions with the boundary values written on them
(plot.qdm_boundary).
Usage
qdm_boundary(
design,
n_t = NULL,
mean_t = NULL,
sd_t = NULL,
cov_t = NULL,
events_t = NULL,
exposure_t = NULL,
data_c = NULL,
seed = NULL
)
Arguments
design |
A design created by |
n_t |
Numbers of subjects in the treatment group (whole numbers); by
default that of the design. Several values are allowed for one binary
endpoint without a concurrent control group and for one continuous
endpoint. For a time-to-event endpoint, |
mean_t |
For one continuous endpoint, an optional numeric vector: the grid of observed treatment means on which the boundary values are searched. For two continuous endpoints, a list of two numeric vectors: the observed treatment means of endpoint 1 (the conditions) and the grid of observed treatment means of endpoint 2. |
sd_t |
Observed treatment standard deviations (one continuous endpoint; positive). |
cov_t |
Observed treatment covariance matrix (two continuous endpoints; a 2 x 2 positive definite matrix). |
events_t |
Numbers of events of the treatment group (time-to-event
endpoint; whole numbers); by default |
exposure_t |
Total observed times of the treatment group (time-to-event endpoint; positive). |
data_c |
Observed data of the concurrent control group, created by
|
seed |
Random seed for probabilities computed by Monte Carlo
simulation, or |
Details
The observed quantity and the conditions depend on the endpoint:
- One binary endpoint
The number of responders of the treatment group
y_t = 0, \ldots, n_t. With a concurrent control group, one set of intervals for each number of control respondersy_c = 0, \ldots, n_c(n_tmust be a single number;n_cis that of the design). Without one, one set for each sample size inn_t, which shows how the boundary changes with the sample size.- One continuous endpoint
The observed treatment mean, for each combination of
sd_tandn_t(at most one of them may have more than one value). With a concurrent control group,data_cgives the observed control data. The boundary values are located by bisection between the values of a grid,mean_tor by default a grid of 201 values that covers the thresholds of the criterion.- Two continuous endpoints
The observed treatment mean of endpoint 2, located by bisection on the grid
mean_t[[2]], for each observed treatment mean of endpoint 1 inmean_t[[1]], with the sample covariance matrixcov_tandn_tsubjects (a single number). With a concurrent control group,data_cgives the observed control data.- One time-to-event endpoint
The number of events of the treatment group (
events_t), for each total observed time inexposure_t. With a concurrent control group,data_cgives the observed control data.
Two binary endpoints are not supported, because their decision depends on the four cell counts and cannot be summarized by one observed quantity.
The decision for each value is made as in qdm_decide. For an
observed mean, the first and last intervals extend to minus and plus
infinity; changes of the decision beyond the grid (whose ends are
extended by two values far beyond them) or two changes of the same
criterion between two neighboring grid values are not detected. With a
conjugate (Normal-Inverse-chi-squared) prior, the posterior scale
increases with the distance between the observed mean and the prior
mean, so the probability of the Go region need not increase with the
observed mean; the intervals then show where it decreases again.
Probabilities computed by Monte Carlo simulation (method = "MC",
or posterior predictive probabilities of a time-to-event endpoint) make
the boundary values approximate.
Value
An object of class c("qdm_boundary", "data.frame") with one
row per decision interval and the columns
- Conditions
n_t,n_candy_c(binary; onlyn_twithout a concurrent control group),n_tandsd_t(continuous),n_t,mean_t1andeffect1(two continuous endpoints; the observed treatment mean of endpoint 1 and its difference from the control) orexposure_t(time-to-event).- decision
The decision (a factor with levels
"Go","NoGo","Gray"and"Miss").- from, to
The ends of the interval of the observed quantity: the number of treatment responders or events (both ends included), or the observed treatment mean (of endpoint 2).
- rate_from, rate_to
Binary endpoint: the observed response rates
y_t / n_tat the ends.- surv_from, surv_to
Time-to-event endpoint evaluated by the milestone survival: the observed milestone survival probabilities
\exp(-t_0 d_t / E_t)at the ends.- effect_from, effect_to
The observed treatment effect at the ends: the observed rate, mean or milestone survival minus that of the concurrent control group, or minus the fixed control value or the mean (location) of the distribution of the control group; for the hazard ratio, the observed hazard
d_t / E_tdivided by the observed control hazard (NAif the control group has no events), the fixed control hazard or the mean of the distribution of the control hazard. The values correspond tofromandto, soeffect_fromis larger thaneffect_towhen larger values of the observed quantity give smaller effects (for example, more events and the milestone survival).
The attributes design, axes, titles,
increasing, discrete and range record the design
and the information used by the print and plot methods.
See Also
Other operations:
qdm_calibrate(),
qdm_compare(),
qdm_decide(),
qdm_find_n(),
qdm_oc(),
qdm_scenarios()
Examples
# Single-arm study with a fixed control response rate of 0.2: responders
# needed out of 10 to 30 subjects
des <- design_binary(
n_t = 20, n_c = 0, prior_t = prior_beta(1, 1),
criterion = criterion_posterior(theta_tv = 0.2, theta_mav = 0.05,
gamma_go = 0.8, gamma_nogo = 0.8),
fixed_c = 0.2
)
b <- qdm_boundary(des, n_t = c(10, 20, 30))
b
plot(b)
# Continuous endpoint with a concurrent control group: observed
# differences in means needed for each observed standard deviation
des2 <- design_continuous(
n_t = 12, n_c = 12,
prior_t = prior_vague(), prior_c = prior_vague(),
criterion = criterion_posterior(theta_tv = 30, theta_mav = 15,
gamma_go = 0.6, gamma_nogo = 0.7),
method = "MM"
)
b2 <- qdm_boundary(des2, sd_t = c(20, 25, 30),
data_c = data_continuous(12, 0, 25))
b2
plot(b2)
Build a design from a design specification
Description
Creates the design specified step by step from qdm_endpoint,
by calling the design_*() function of the endpoint
(design_binary, design_continuous,
design_binary2, design_continuous2 or
design_tte) with the arguments set. The design is identical
to the one created by calling that function directly with the same
arguments, and invalid arguments give the same errors. The sample sizes
(qdm_sample_size), the prior distribution of the treatment
group (qdm_prior) and the decision criterion
(qdm_criterion) must have been set.
Usage
qdm_build(x)
Arguments
x |
A design specification started by |
Value
A design, an object of class "qdm_design", as returned by
the design_*() function of the endpoint.
See Also
Other design steps:
qdm_computation(),
qdm_control(),
qdm_criterion(),
qdm_endpoint(),
qdm_external(),
qdm_prior(),
qdm_sample_size(),
qdm_tte()
Examples
qdm_endpoint("binary") |>
qdm_sample_size(n_t = 12, n_c = 12) |>
qdm_prior(prior_t = prior_beta(0.5, 0.5),
prior_c = prior_beta(0.5, 0.5)) |>
qdm_criterion(criterion_posterior(theta_tv = 0.2, theta_mav = 0.1,
gamma_go = 0.5, gamma_nogo = 0.8)) |>
qdm_build()
Calibration of the decision thresholds
Description
Chooses the thresholds \gamma_{go} and \gamma_{nogo} of the
criterion of a design so that the probabilities of a false Go decision and
a false NoGo decision are controlled.
Usage
qdm_calibrate(
design,
scenario_go,
scenario_nogo,
target_go,
target_nogo,
grid = (1:99)/100,
nsim = 10000L,
seed = NULL
)
Arguments
design |
A design created by |
scenario_go, scenario_nogo |
Data frames with one row each, giving the
scenarios used to calibrate |
target_go, target_nogo |
Upper bounds for the probabilities that the
Go criterion is met under |
grid |
Candidate thresholds, strictly between 0 and 1. The default
gives 0.01, 0.02, ..., 0.99 as the numbers written with two decimals
( |
nsim, seed |
As in |
Details
The threshold \gamma_{go} is the smallest value in grid for
which the probability that the Go criterion is met under
scenario_go, a scenario under which a Go decision would be wrong
(typically with no or a small treatment effect), is at most
target_go. The threshold \gamma_{nogo} is the smallest value
in grid for which the probability that the NoGo criterion is met
under scenario_nogo, a scenario under which a NoGo decision would
be wrong (typically with the expected treatment effect), is at most
target_nogo. Both
probabilities decrease as the threshold increases, so the chosen thresholds
are the least strict ones that meet the targets.
The decision probabilities of the design with the chosen thresholds are
computed under both scenarios. If \gamma_{go} + \gamma_{nogo} \le 1
(and, for two endpoints with the marginal rule "or", for any
thresholds), Miss decisions (both criteria met) can occur, and a warning is
given when they have positive probability.
Value
An object of class "qdm_calibration": a list with elements
- gamma_go, gamma_nogo
The chosen thresholds (
NAif no value ingridmeets the target).- prob_go, prob_nogo
The probabilities that the Go criterion is met under
scenario_goand that the NoGo criterion is met underscenario_nogo, at the chosen thresholds.- target_go, target_nogo
The targets.
- curve
A data frame with the columns
gamma(the grid),prob_goandprob_nogo(the two probabilities at each threshold).- oc
A data frame of the decision probabilities with the chosen thresholds under the two scenarios (
NULLif a threshold was not found).- design
The design with the chosen thresholds (
NULLif a threshold was not found).- scenario_go, scenario_nogo, method
The scenarios and the method of computation.
See Also
Other operations:
qdm_boundary(),
qdm_compare(),
qdm_decide(),
qdm_find_n(),
qdm_oc(),
qdm_scenarios()
Examples
des <- design_binary(
n_t = 12, n_c = 12,
prior_t = prior_beta(0.5, 0.5), prior_c = prior_beta(0.5, 0.5),
criterion = criterion_posterior(theta_tv = 0.2, theta_mav = 0.1,
gamma_go = 0.5, gamma_nogo = 0.8)
)
cal <- qdm_calibrate(des,
scenario_go = data.frame(pi_t = 0.4, pi_c = 0.4),
scenario_nogo = data.frame(pi_t = 0.7, pi_c = 0.4),
target_go = 0.05, target_nogo = 0.2)
cal
plot(cal)
cal$design
Operating characteristics of several designs
Description
Computes the operating characteristics of several designs under the same scenarios, for example designs with different sample sizes, prior distributions, external data or thresholds, and collects them in one table with a column that names the design.
Usage
qdm_compare(designs, scenarios, nsim = 10000L, seed = NULL)
Arguments
designs |
A list of designs (created by a |
scenarios |
A data frame of scenarios with the columns needed by all
the designs (see |
nsim, seed |
As in |
Details
Each design is computed by qdm_oc with the same
scenarios, nsim and seed, so the rows of a design
are those of qdm_oc() for that design alone. With a seed, the
simulated studies of all designs start from the same random numbers. The
warnings of qdm_oc() (Miss decisions, scenarios that are not
evaluable) start with the name of the design.
Designs that differ in one part can be made from one design with the
design steps (see qdm_endpoint), which accept a design; for
example, for several sample sizes,
lapply(c(12, 18, 24), function(n) qdm_sample_size(des, n, n)).
Value
An object of class c("qdm_comparison", "data.frame"): the
column design (a factor with the names of the designs as levels,
in the order of designs), followed by the columns of the results
of qdm_oc (the scenarios and the probabilities of the
decisions). The attribute designs is the list of the designs
(built from the specifications) and the attribute method the
methods of computation, named by the designs.
See Also
Other operations:
qdm_boundary(),
qdm_calibrate(),
qdm_decide(),
qdm_find_n(),
qdm_oc(),
qdm_scenarios()
Examples
des <- design_binary(
n_t = 12, n_c = 12,
prior_t = prior_beta(0.5, 0.5), prior_c = prior_beta(0.5, 0.5),
criterion = criterion_posterior(theta_tv = 0.2, theta_mav = 0.1,
gamma_go = 0.5, gamma_nogo = 0.8)
)
n <- c(12, 18, 24)
designs <- lapply(n, function(k) qdm_sample_size(des, n_t = k, n_c = k))
names(designs) <- paste(n, "per group")
cmp <- qdm_compare(designs, qdm_scenarios(des, theta = seq(0, 0.4, by = 0.1),
pi_c = 0.3))
cmp
plot(cmp)
# Borrowing of external control data
ext <- qdm_external(des, external_c = borrow(data_binary(40, 12), 0.5))
qdm_compare(list(Concurrent = des, Borrowing = ext),
data.frame(pi_t = c(0.3, 0.6), pi_c = 0.3))
Set the computation of the probabilities of a design specification
Description
Sets the arguments of the design_*() function that choose how the
probabilities of the regions are computed. Each endpoint has only some of
them: method for one or two continuous endpoints, nMC for
one continuous endpoint, two binary endpoints, two continuous endpoints and
a time-to-event endpoint, and enumerate for two binary endpoints. An
argument that the design_*() function of the endpoint does not have
is an error. The values are checked when the design is built, by the
design_*() function. All the arguments of the step are set together:
an argument that is not given returns to the default, so
qdm_computation(x, nMC = 5000) also returns method to its
default.
Usage
qdm_computation(x, method = NULL, nMC = NULL, enumerate = NULL)
Arguments
x |
A design specification started by |
method |
Method of computation of the probabilities:
|
nMC |
Number of Monte Carlo draws or simulated future studies, or
|
enumerate |
For two binary endpoints, whether the operating
characteristics enumerate all outcomes (see
|
Value
A design specification: x, or the specification of the
design x, with the arguments set.
See Also
Other design steps:
qdm_build(),
qdm_control(),
qdm_criterion(),
qdm_endpoint(),
qdm_external(),
qdm_prior(),
qdm_sample_size(),
qdm_tte()
Examples
qdm_endpoint("continuous") |>
qdm_computation(method = "MM")
Set a hypothetical or fixed control of a design specification
Description
Sets the arguments hypothetical_c and fixed_c of a design
specification started by qdm_endpoint, for a study without
a concurrent control group (n_c = 0, see
qdm_sample_size). A concurrent control group and external
control data only (see qdm_external) need no call of this
function. The arguments are checked when the design is built, by the
design_*() function of the endpoint. All the arguments of the step
are set together: an argument that is not given returns to the default, so
a hypothetical control replaces a fixed control and the other way round.
Usage
qdm_control(x, hypothetical_c = NULL, fixed_c = NULL)
Arguments
x |
A design specification started by |
hypothetical_c |
Hypothetical control, created by
|
fixed_c |
Fixed value of the control parameter, or |
Value
A design specification: x, or the specification of the
design x, with the control set.
See Also
Other design steps:
qdm_build(),
qdm_computation(),
qdm_criterion(),
qdm_endpoint(),
qdm_external(),
qdm_prior(),
qdm_sample_size(),
qdm_tte()
Examples
# Single-arm study compared with a fixed control response rate of 0.2
qdm_endpoint("binary") |>
qdm_sample_size(n_t = 20, n_c = 0) |>
qdm_prior(prior_t = prior_beta(1, 1)) |>
qdm_criterion(criterion_posterior(theta_tv = 0.2, theta_mav = 0.05,
gamma_go = 0.8, gamma_nogo = 0.8)) |>
qdm_control(fixed_c = 0.2)
Set the decision criterion of a design specification
Description
Sets the argument criterion of a design specification started by
qdm_endpoint. It is checked when the design is built, by the
design_*() function of the endpoint.
Usage
qdm_criterion(x, criterion)
Arguments
x |
A design specification started by |
criterion |
Decision criterion created by
|
Value
A design specification: x, or the specification of the
design x, with the decision criterion set.
See Also
Other design steps:
qdm_build(),
qdm_computation(),
qdm_control(),
qdm_endpoint(),
qdm_external(),
qdm_prior(),
qdm_sample_size(),
qdm_tte()
Examples
qdm_endpoint("binary") |>
qdm_criterion(criterion_posterior(theta_tv = 0.2, theta_mav = 0.1,
gamma_go = 0.5, gamma_nogo = 0.8))
Go/NoGo decision for observed data
Description
Computes the probabilities of the Go and NoGo regions given the observed proof-of-concept data, and makes the decision of a design.
Usage
qdm_decide(design, data_t, data_c = NULL, seed = NULL)
Arguments
design |
A design created by |
data_t |
Observed data of the treatment group, created by
|
data_c |
Observed data of the concurrent control group, created by
the same function as |
seed |
Random seed for probabilities computed by Monte Carlo
simulation (a continuous design with |
Details
The decision is Go if only the Go criterion is met, NoGo if only the NoGo
criterion is met, Gray if neither is met, and Miss if both are met (see
criterion_posterior and criterion_predictive).
A probability that is below a threshold by less than 10^{-10} is
treated as equal to the threshold, so that ties that arise in symmetric
settings are not decided by rounding errors.
The sample sizes of the observed data may differ from those of the design,
which are used only by qdm_oc and qdm_calibrate.
Value
An object of class "qdm_decision": a list with elements
- decision
"Go","NoGo","Gray"or"Miss".- prob_go, prob_nogo
Probabilities of the Go and NoGo regions (for two endpoints with a marginal rule, one probability per endpoint).
- prob_regions
For two endpoints, the probabilities of all regions (see
qdm_regions);NULLotherwise.- met_go, met_nogo
Whether the Go and NoGo criteria are met.
- posterior_t, posterior_c
Parameters of the posterior distributions of the treatment and control groups: for a binary endpoint, the Beta parameters
aandb; for a continuous endpoint, the Normal-Inverse-chi-squared parametersmu,kappa,nuandsigma(on the standard deviation scale), so that the mean has the distributiont_{\nu}(\mu, \sigma^2 / \kappa). For a hypothetical control,posterior_cgives the distribution of the control mean in the same form (seedesign_continuous). For two binary endpoints, the Dirichlet parameters of the cells"00","01","10"and"11". For two continuous endpoints, the Normal-Inverse-Wishart parametersmu1,mu2,kappa,nuand the elementsL11,L12andL22of\Lambda, so that the mean has the distributiont_{\nu - 1}(\mu, \Lambda / (\kappa (\nu - 1))). For a time-to-event endpoint, the shape and rate of the Gamma distribution of the hazard. For a fixed control,posterior_cis the fixed value (namedvalue, orvalue1andvalue2for two endpoints).- design, data_t, data_c
The arguments.
See Also
Other operations:
qdm_boundary(),
qdm_calibrate(),
qdm_compare(),
qdm_find_n(),
qdm_oc(),
qdm_scenarios()
Examples
des <- design_binary(
n_t = 12, n_c = 12,
prior_t = prior_beta(0.5, 0.5), prior_c = prior_beta(0.5, 0.5),
criterion = criterion_posterior(theta_tv = 0.2, theta_mav = 0.1,
gamma_go = 0.5, gamma_nogo = 0.8)
)
qdm_decide(des, data_t = data_binary(12, 9), data_c = data_binary(12, 4))
# Continuous endpoint
des2 <- design_continuous(
n_t = 12, n_c = 12,
prior_t = prior_vague(), prior_c = prior_vague(),
criterion = criterion_posterior(theta_tv = 30, theta_mav = 15,
gamma_go = 0.6, gamma_nogo = 0.7)
)
qdm_decide(des2, data_t = data_continuous(12, 18, 25),
data_c = data_continuous(12, -12, 25))
Start a design specification for an endpoint
Description
Starts the specification of a design that is built step by step, for
example with the native pipe |> of R. The other steps set the
arguments of the design_*() function of the endpoint:
qdm_sample_sizen_tandn_c;qdm_priorprior_tandprior_c;qdm_criterioncriterion;qdm_externalexternal_tandexternal_c;qdm_controlhypothetical_candfixed_c;qdm_ttemilestone,effect,conductandconduct_future(time-to-event endpoint);qdm_computationmethod,nMCandenumerate.
qdm_build creates the design with the design_*()
function of the endpoint.
Usage
qdm_endpoint(endpoint)
Arguments
endpoint |
Type of endpoint: |
Details
The steps only store their arguments, so they can be given in any order.
A step given again sets all its arguments anew: an argument that is not
given, or is given as NULL, returns to the default of the
design_*() function. The arguments are checked when the design is
built, by the design_*() function, so the design and its error
messages are those of that function. qdm_decide,
qdm_oc, qdm_compare,
qdm_calibrate, qdm_find_n,
qdm_boundary and qdm_scenarios accept a
specification in place of a design and build it, and
show_report and show_code accept it as well.
A design created by a design_*() function can also be given to the
steps and to qdm_build: it is converted to the
specification that builds it (the arguments that are NULL in the
design are not set), so that one part of a design can be changed with a
step, for example
design_binary(...) |> qdm_sample_size(n_t = 20, n_c = 20).
As with a step given again, all the arguments of the step are set: for
example, qdm_external(des, external_c = ...) also removes the
external data of the treatment group of des.
Value
An object of class "qdm_spec", a list with the elements
endpoint and args (the arguments of the design_*()
function set so far, none at the start).
See Also
Other design steps:
qdm_build(),
qdm_computation(),
qdm_control(),
qdm_criterion(),
qdm_external(),
qdm_prior(),
qdm_sample_size(),
qdm_tte()
Examples
spec <- qdm_endpoint("binary") |>
qdm_sample_size(n_t = 12, n_c = 12) |>
qdm_prior(prior_t = prior_beta(0.5, 0.5),
prior_c = prior_beta(0.5, 0.5)) |>
qdm_criterion(criterion_posterior(theta_tv = 0.2, theta_mav = 0.1,
gamma_go = 0.5, gamma_nogo = 0.8))
spec
# The same design as with design_binary()
des <- design_binary(
n_t = 12, n_c = 12,
prior_t = prior_beta(0.5, 0.5), prior_c = prior_beta(0.5, 0.5),
criterion = criterion_posterior(theta_tv = 0.2, theta_mav = 0.1,
gamma_go = 0.5, gamma_nogo = 0.8)
)
identical(qdm_build(spec), des)
# The specification is built by the functions that use a design
spec |>
qdm_decide(data_t = data_binary(12, 9), data_c = data_binary(12, 4))
Set the external data of a design specification
Description
Sets the arguments external_t and external_c of a design
specification started by qdm_endpoint: external data of the
treatment and control groups, borrowed through a power prior. With
n_c = 0 (see qdm_sample_size) and external control
data, the control group is the external control data only. The arguments
are checked when the design is built, by the design_*() function of
the endpoint. All the arguments of the step are set together: an argument
that is not given returns to the default, so
qdm_external(x, external_c = ...) also removes the external data of
the treatment group of x.
Usage
qdm_external(x, external_t = NULL, external_c = NULL)
Arguments
x |
A design specification started by |
external_t, external_c |
External data of the treatment and control
groups, created by |
Value
A design specification: x, or the specification of the
design x, with the external data set.
See Also
Other design steps:
qdm_build(),
qdm_computation(),
qdm_control(),
qdm_criterion(),
qdm_endpoint(),
qdm_prior(),
qdm_sample_size(),
qdm_tte()
Examples
qdm_endpoint("binary") |>
qdm_external(external_c = borrow(data_binary(n = 20, y = 8), a0 = 0.5))
Search for the sample size
Description
Finds the smallest sample size, among candidates, for which the
probabilities of a false Go decision and a false NoGo decision are
controlled, with the thresholds of the criterion of the design fixed. It
is the counterpart of qdm_calibrate, which fixes the sample
size and chooses the thresholds.
Usage
qdm_find_n(
design,
scenario_go,
scenario_nogo,
target_go,
target_nogo,
n_t,
n_c = NULL,
nsim = 10000L,
seed = NULL
)
Arguments
design |
A design created by |
scenario_go, scenario_nogo, target_go, target_nogo |
As in
|
n_t |
Candidate numbers of subjects in the treatment group (distinct whole numbers, in any order; they are sorted). |
n_c |
Candidate numbers of subjects in the concurrent control group,
one per candidate of |
nsim, seed |
As in |
Details
For each candidate, the design with the sample sizes n_t[k] and
n_c[k] (set by qdm_sample_size) gives the
probability that the Go criterion is met under scenario_go, a
scenario under which a Go decision would be wrong (typically with no or a
small treatment effect), and the probability that the NoGo criterion is
met under scenario_nogo, a scenario under which a NoGo decision
would be wrong (typically with the expected treatment effect), computed
as in
qdm_calibrate. A candidate meets the targets when the first
probability is at most target_go and the second at most
target_nogo.
The probabilities need not decrease as the sample size increases: for a
binary endpoint they change in steps, so that a larger sample size can
fail the targets that a smaller one meets. The result therefore gives both
the smallest candidate that meets the targets (n_t and n_c)
and the smallest candidate from which every larger candidate also meets
them (n_t_stable and n_c_stable).
With a seed, the simulated studies of all candidates start from the same
random numbers, so the differences between candidates are less affected by
the simulation error than with seed = NULL, under which each
candidate continues the random number stream. For a continuous or
time-to-event endpoint, many candidates and the default nsim can
take long; method = "MM" (continuous endpoints) or a smaller
nsim gives a first answer quickly.
Value
An object of class "qdm_n_search": a list with elements
- n_t, n_c
The smallest candidate that meets the targets (
NAif none does).- n_t_stable, n_c_stable
The smallest candidate from which every larger candidate also meets the targets (
NAif the largest candidate does not meet them).- prob_go, prob_nogo
The probabilities that the Go criterion is met under
scenario_goand that the NoGo criterion is met underscenario_nogo, forn_tandn_c.- target_go, target_nogo
The targets.
- curve
A data frame with the columns
n_t,n_c,prob_go,prob_nogoandmet(whether both targets are met), one row per candidate.- oc
A data frame of the decision probabilities with
n_tandn_cunder the two scenarios (NULLif no candidate meets the targets).- design
The design with
n_tandn_c(NULLif no candidate meets the targets).- scenario_go, scenario_nogo, method
The scenarios and the method of computation.
See Also
Other operations:
qdm_boundary(),
qdm_calibrate(),
qdm_compare(),
qdm_decide(),
qdm_oc(),
qdm_scenarios()
Examples
des <- design_binary(
n_t = 12, n_c = 12,
prior_t = prior_beta(0.5, 0.5), prior_c = prior_beta(0.5, 0.5),
criterion = criterion_posterior(theta_tv = 0.2, theta_mav = 0.1,
gamma_go = 0.5, gamma_nogo = 0.8)
)
res <- qdm_find_n(des,
scenario_go = data.frame(pi_t = 0.4, pi_c = 0.4),
scenario_nogo = data.frame(pi_t = 0.7, pi_c = 0.4),
target_go = 0.1, target_nogo = 0.1,
n_t = seq(6, 30, by = 2))
res
plot(res)
res$design
Operating characteristics of a design
Description
Computes the probabilities of Go, NoGo, Gray and Miss decisions of a design under scenarios for the true parameters.
Usage
qdm_oc(design, scenarios, nsim = 10000L, seed = NULL)
Arguments
design |
A design created by |
scenarios |
A data frame with one row per scenario. For a binary
endpoint the columns |
nsim |
Number of simulated studies per scenario for designs whose operating characteristics are computed by simulation. |
seed |
Random seed for the simulation and for Monte Carlo estimates
of probabilities, or |
Details
For a binary endpoint, all possible outcomes of the proof-of-concept study
are enumerated and the probabilities are exact (Kang et al., 2026, Section
4.3); nsim and seed are not used.
For a continuous endpoint, nsim studies are simulated under each
scenario. Only the sufficient statistics are simulated: the sample mean
\bar y = \mu + \sigma Z / \sqrt{n} and the sample standard deviation
s = \sigma \sqrt{X / (n - 1)}, with Z \sim N(0, 1) and
X \sim \chi^2_{n - 1}. The same random numbers are used for all
scenarios, so the results change smoothly across scenarios. The
probabilities have a simulation standard error of at most
0.5 / \sqrt{nsim} (0.005 for the default nsim). For each
simulated study, the probabilities of the Go and NoGo regions are computed
by the method of the design (see design_continuous), of which
method = "MM" is the fastest. To explore many scenarios or designs,
method = "MM" or a smaller nsim gives results quickly; the
chosen design can then be checked with method = "NI" and the
default nsim.
For two binary endpoints, all outcomes are enumerated (Yamaguchi et al.,
submitted, equation A.5) or nsim studies are simulated, as specified
by enumerate in design_binary2. The response rates
and correlation of each group are converted to cell probabilities by
cellprob_binary2; a scenario whose correlation is outside the
feasible range for its response rates is not evaluable, and its
probabilities are NA (with a warning).
For two continuous endpoints, nsim studies are simulated under each
scenario. Only the sufficient statistics are simulated: the sample means
\bar y = \mu + L z / \sqrt{n} and the matrix of sums of squares and
cross-products S = L A A^T L^T, where L is the Cholesky
factor of the covariance matrix of the scenario, z has two
independent standard normal elements and A is the Bartlett factor
of a Wishart distribution with n - 1 degrees of freedom. The same
random numbers are used for all scenarios.
For a time-to-event endpoint, nsim studies are simulated under each
scenario as specified by the conduct of the design (enrollment, dropout
and analysis time; see conduct_tte), with exponential event
times whose hazard is \log(2) / M for the median survival time
M of the scenario. The same random numbers are used for all
scenarios. With a predictive criterion, every simulated study needs
nMC simulated future studies (see design_tte), so
the computing time grows with nsim times nMC.
The decision for each outcome is made as in qdm_decide. A
warning is given when Miss decisions (both criteria met) have positive
probability in some scenario.
Value
An object of class c("qdm_oc", "data.frame"): the scenarios
with the columns Go, NoGo, Gray and Miss
added. The attributes design and method record the design
and the method of computation.
References
Kang, R., Yamaguchi, Y. and Han, C. (2026). Bayesian quantitative decision-making framework in cell and gene therapy development for rare diseases. Journal of Biopharmaceutical Statistics. doi:10.1080/10543406.2026.2655410
Yamaguchi, Y., Hu, H., Huang, Y., Han, C., Homma, G. and Wang, A. (submitted). Bivariate Bayesian quantitative decision-making for two endpoints in rare disease drug development.
See Also
Other operations:
qdm_boundary(),
qdm_calibrate(),
qdm_compare(),
qdm_decide(),
qdm_find_n(),
qdm_scenarios()
Examples
des <- design_binary(
n_t = 12, n_c = 12,
prior_t = prior_beta(0.5, 0.5), prior_c = prior_beta(0.5, 0.5),
criterion = criterion_posterior(theta_tv = 0.2, theta_mav = 0.1,
gamma_go = 0.5, gamma_nogo = 0.8)
)
oc <- qdm_oc(des, data.frame(pi_t = seq(0.2, 0.8, by = 0.1), pi_c = 0.4))
oc
plot(oc)
# Continuous endpoint (moment-matching approximation for speed)
des2 <- design_continuous(
n_t = 12, n_c = 12,
prior_t = prior_vague(), prior_c = prior_vague(),
criterion = criterion_posterior(theta_tv = 30, theta_mav = 15,
gamma_go = 0.6, gamma_nogo = 0.7),
method = "MM"
)
oc2 <- qdm_oc(des2, data.frame(mu_t = seq(0, 50, by = 10), sd_t = 25,
mu_c = 0, sd_c = 25),
nsim = 2000, seed = 1)
oc2
# Two binary endpoints (small nMC for speed)
des3 <- design_binary2(
n_t = 6, n_c = 6,
prior_t = prior_dirichlet(rep(0.25, 4)),
prior_c = prior_dirichlet(rep(0.25, 4)),
criterion = criterion_posterior(theta_tv = c(0.15, 0.15),
theta_mav = c(0.10, 0.10),
gamma_go = 0.3, gamma_nogo = 0.4),
nMC = 2000
)
effects <- expand.grid(theta1 = c(0, 0.15, 0.3), theta2 = c(0, 0.15, 0.3))
oc3 <- qdm_oc(des3, data.frame(pi_t1 = 0.2 + effects$theta1,
pi_t2 = 0.2 + effects$theta2, rho_t = 0.3,
pi_c1 = 0.2, pi_c2 = 0.2, rho_c = 0.3),
seed = 1)
oc3
plot(oc3)
Set the prior distributions of a design specification
Description
Sets the arguments prior_t and prior_c of a design
specification started by qdm_endpoint. They are checked when
the design is built, by the design_*() function of the endpoint. All
the arguments of the step are set together: an argument that is not given
returns to the default, so qdm_prior(x, prior_t = ...) also removes
prior_c of x.
Usage
qdm_prior(x, prior_t, prior_c = NULL)
Arguments
x |
A design specification started by |
prior_t, prior_c |
Prior distributions of the treatment and control
groups, created by the |
Value
A design specification: x, or the specification of the
design x, with the prior distributions set.
See Also
Other design steps:
qdm_build(),
qdm_computation(),
qdm_control(),
qdm_criterion(),
qdm_endpoint(),
qdm_external(),
qdm_sample_size(),
qdm_tte()
Examples
qdm_endpoint("binary") |>
qdm_prior(prior_t = prior_beta(0.5, 0.5),
prior_c = prior_beta(0.5, 0.5))
Region numbers for two endpoints
Description
Shows how the regions used by the decision criteria for two endpoints are numbered (Yamaguchi et al., submitted, Tables 1 and 2).
Usage
qdm_regions(prob = c("posterior", "predictive"), direction = "greater")
Arguments
prob |
Either |
direction |
|
Details
For posterior probability, the target value (TV) and the minimum acceptable
value (MAV) of each endpoint divide the plane of (\theta_1, \theta_2)
into nine regions. Columns correspond to endpoint 1 and rows to endpoint 2.
For posterior predictive probability, the null values divide the plane into
four regions.
For an endpoint on which smaller effects are favorable
(direction = "less" in the criterion), the inequalities of that
endpoint are reversed, so that region 1 is always the most favorable one:
for example, "theta2 < TV2", "TV2 <= theta2 < MAV2" and
"theta2 >= MAV2".
Value
A character matrix of region labels (printed without quotes), with the conditions on endpoint 1 as column names and those on endpoint 2 as row names.
References
Yamaguchi, Y., Hu, H., Huang, Y., Han, C., Homma, G. and Wang, A. (submitted). Bivariate Bayesian quantitative decision-making for two endpoints in rare disease drug development.
Examples
qdm_regions("posterior")
qdm_regions("predictive")
# Endpoint 2 is a safety endpoint (smaller effects are favorable)
qdm_regions("posterior", direction = c("greater", "less"))
Set the sample sizes of a design specification
Description
Sets the arguments n_t and n_c of a design specification
started by qdm_endpoint. They are checked when the design is
built, by the design_*() function of the endpoint.
Usage
qdm_sample_size(x, n_t, n_c)
Arguments
x |
A design specification started by |
n_t |
Number of subjects in the treatment group. |
n_c |
Number of subjects in the concurrent control group: 0 for a study without a concurrent control group (external control data only, a hypothetical control or a fixed control). |
Value
A design specification: x, or the specification of the
design x, with the sample sizes set.
See Also
Other design steps:
qdm_build(),
qdm_computation(),
qdm_control(),
qdm_criterion(),
qdm_endpoint(),
qdm_external(),
qdm_prior(),
qdm_tte()
Examples
qdm_endpoint("binary") |>
qdm_sample_size(n_t = 12, n_c = 12)
Scenarios for the operating characteristics
Description
Creates the data frame of scenarios for the true parameters that
qdm_oc, qdm_compare, qdm_calibrate
and qdm_find_n use, with the columns that the design needs
(see qdm_oc). Missing, unknown and repeated columns are
errors.
Usage
qdm_scenarios(design, ..., theta = NULL, grid = TRUE)
Arguments
design |
A design created by |
... |
Named numeric vectors: the values of the columns of the scenarios. |
theta |
|
grid |
|
Details
The values of the columns are given in ..., for example
pi_t = seq(0.2, 0.8, by = 0.1), pi_c = 0.4 for one binary
endpoint. A name without the letter of the group gives the same value to
both groups: sd for a continuous endpoint (sd_t and
sd_c), rho for two binary endpoints (rho_t and
rho_c), and sd1, sd2 and rho for two
continuous endpoints. The columns of the control group are not used for a
design without a concurrent control group. The correlations of two
endpoints have no default value, because the operating characteristics
depend on them (for two binary endpoints, the feasible correlations also
depend on the response rates; see cellprob_binary2).
Alternatively, the scenarios can be given by the treatment effect
theta, on the scale of the decision criterion and of the
horizontal axis of the plots of qdm_oc. The parameter of the
treatment group that sets the effect (pi_t, mu_t or
median_t; pi_t1 and pi_t2; or mu_t1 and
mu_t2) is then computed, and is not given in .... With a
concurrent control group, the effect is measured from the parameter of
the control group given in ...; without one, from the fixed
control value, or from the mean (binary and time-to-event endpoints) or
the location (continuous endpoints) of the distribution of the control
group. For a time-to-event endpoint evaluated by the milestone survival,
the median survival time of the treatment group is
M_t = -\log(2) t_0 / \log(S_c(t_0) + \theta), where S_c(t_0)
is the milestone survival probability of the control group; for the
hazard ratio \theta = \lambda_t / \lambda_c, it is
M_t = M_c / \theta, or \log(2) / (\theta \lambda_c) without a
concurrent control group, where \lambda_c is the fixed control
hazard or the mean of the distribution of the control hazard.
theta = "thresholds" gives the effects that a study protocol
usually reports: no effect (0, or 1 for a hazard ratio), the minimum
acceptable value and the target value of the criterion (the null value of
a predictive criterion), for each endpoint (repeated values are given
once).
Value
A data frame with one row per scenario: the column theta
(or theta1 and theta2) when theta is given,
followed by the columns of the scenarios in the order given in
qdm_oc.
See Also
Other operations:
qdm_boundary(),
qdm_calibrate(),
qdm_compare(),
qdm_decide(),
qdm_find_n(),
qdm_oc()
Examples
des <- design_binary(
n_t = 12, n_c = 12,
prior_t = prior_beta(0.5, 0.5), prior_c = prior_beta(0.5, 0.5),
criterion = criterion_posterior(theta_tv = 0.2, theta_mav = 0.1,
gamma_go = 0.5, gamma_nogo = 0.8)
)
qdm_scenarios(des, pi_t = seq(0.2, 0.8, by = 0.2), pi_c = 0.4)
# Scenarios given by the effect
qdm_scenarios(des, theta = c(0, 0.1, 0.2, 0.3), pi_c = 0.4)
# No effect, the minimum acceptable value and the target value
scen <- qdm_scenarios(des, theta = "thresholds", pi_c = 0.4)
qdm_oc(des, scen)
# Two continuous endpoints with the same standard deviations and
# correlation in both groups
des2 <- design_continuous2(
n_t = 12, n_c = 12, prior_t = prior_vague(), prior_c = prior_vague(),
criterion = criterion_posterior(theta_tv = c(10, 2), theta_mav = c(5, 1),
gamma_go = 0.5, gamma_nogo = 0.3)
)
qdm_scenarios(des2, theta = list(c(0, 5, 10), c(0, 1, 2)), mu_c1 = 0,
mu_c2 = 0, sd1 = 20, sd2 = 4, rho = 0.3)
Set the arguments of a time-to-event design specification
Description
Sets the arguments of design_tte that are specific to a
time-to-event endpoint: the effect measure, the milestone time and the
conduct of the study and of the future study. The specification must
have been started by qdm_endpoint("tte"). The arguments are checked
when the design is built, by design_tte. All the arguments of
the step are set together: an argument that is not given returns to the
default, so qdm_tte(x, conduct = ...) also removes milestone
and effect of x.
Usage
qdm_tte(
x,
milestone = NULL,
effect = NULL,
conduct = NULL,
conduct_future = NULL
)
Arguments
x |
A design specification started by |
milestone |
Milestone time |
effect |
Effect measure, |
conduct |
Conduct of the study, created by
|
conduct_future |
Conduct of the future study for a predictive
criterion, created by |
Value
A design specification: x, or the specification of the
design x, with the arguments set.
See Also
Other design steps:
qdm_build(),
qdm_computation(),
qdm_control(),
qdm_criterion(),
qdm_endpoint(),
qdm_external(),
qdm_prior(),
qdm_sample_size()
Examples
qdm_endpoint("tte") |>
qdm_sample_size(n_t = 20, n_c = 20) |>
qdm_prior(prior_t = prior_gamma(0.1, 1),
prior_c = prior_gamma(0.1, 1)) |>
qdm_criterion(criterion_posterior(theta_tv = 0.15, theta_mav = 0,
gamma_go = 0.6, gamma_nogo = 0.8)) |>
qdm_tte(milestone = 3,
conduct = conduct_tte(accrual_time = c(0, 5, 10, 15),
accrual_rate = c(0.4, 2, 4.5),
dropout_hazard = 0.00226,
cut_time = 15.44)) |>
qdm_build()
Random generation from the Dirichlet distribution
Description
Draws random vectors from the Dirichlet distribution by normalizing independent Gamma variables, using the random number generator of R.
Usage
rdirichlet(n, alpha)
Arguments
n |
Number of draws (a whole number of at least 1). |
alpha |
Numeric vector of at least two positive concentration parameters. |
Value
A numeric matrix with n rows and length(alpha)
columns whose rows sum to 1 (a matrix is returned even when
n = 1). Column names are taken from names(alpha).
See Also
Other distributions:
cellprob_binary2(),
pbetabinomdiff(),
pbetadiff(),
phazardratio(),
psurvdiff(),
ptdiff()
Examples
set.seed(1)
rdirichlet(3, c(1.5, 0.5, 2, 1))
R code of a design
Description
Writes the R code that creates a design: a pipe of the design steps that
starts with qdm_endpoint and ends with
qdm_build, or a call of the design_*() function of
the endpoint. Evaluating the code gives a design identical to the
original. The code can be kept with a study protocol or a report (see the
argument code of show_report), or used as the start
of a new analysis.
Usage
show_code(x, style = c("pipe", "design"), name = "design")
Arguments
x |
A design (created by a |
style |
|
name |
Name to which the code assigns the design, or |
Details
The arguments are written with the values that the design keeps (the
numbers with the fewest digits that give them exactly), and the arguments
equal to their defaults are left out. For a design specification, the
code of the pipe gives the specification (without qdm_build()).
For a result of an analysis, the code creates the design of the result;
the scenarios, the number of simulated studies and the seed of the
analysis are not part of the code.
Value
An object of class "qdm_code": a character vector with one
line of code per element, which is printed as the code.
Examples
des <- design_binary(
n_t = 12, n_c = 12,
prior_t = prior_beta(0.5, 0.5), prior_c = prior_beta(0.5, 0.5),
criterion = criterion_posterior(theta_tv = 0.2, theta_mav = 0.1,
gamma_go = 0.5, gamma_nogo = 0.8),
external_c = borrow(data_binary(n = 40, y = 12), a0 = 0.5)
)
show_code(des)
show_code(des, style = "design")
# The code gives the same design
code <- show_code(des, name = NULL)
identical(eval(parse(text = code)), des)
Write a report of a design and its results
Description
Writes a report of a design, or of the result of an analysis of a design,
as a draft of the corresponding sections of a study protocol: the study
design, the statistical model and the prior distributions, the decision
criteria with their formulas, the computation of the probabilities and the
result. The report is meant to be copied into a protocol and edited there.
It can end a pipe of the design steps (see qdm_endpoint) and
of the functions that use a design.
Usage
show_report(
x,
file_type = c("html", "text"),
file = NULL,
title = NULL,
digits = 3L,
open = interactive(),
code = FALSE
)
Arguments
x |
A design (created by a |
file_type |
|
file |
Name of the file to write, or |
title |
Title of the report, or |
digits |
Number of decimal places of the probabilities (a whole number from 1 to 10). The parameters are shown with up to four significant digits. |
open |
Whether to show the report: an HTML report is opened in the viewer of RStudio, if the file is in the temporary folder of the R session, or else in the web browser, and a text report is printed in the console. By default the report is shown when R is used interactively. |
code |
|
Details
The content of the report depends on x:
- A design or a design specification
The design.
- A result of
qdm_oc The design and the table of the operating characteristics.
- A result of
qdm_calibrate The design with the calibrated thresholds, how the thresholds were chosen, and the decision probabilities under the two scenarios of the calibration.
- A result of
qdm_find_n The design with the chosen sample sizes, how they were chosen, the probabilities for the candidates and the decision probabilities under the two scenarios.
- A result of
qdm_boundary The design and the decision boundaries.
- A result of
qdm_decide The design, the observed data, the probabilities of the criteria, the decision and the posterior distributions.
The formulas are written in LaTeX between dollar signs. In the HTML report they are displayed by MathJax, which the web browser loads from a content delivery network, so an internet connection is needed to display them (without one, the LaTeX code is shown). The text report is plain text in Markdown format, with the formulas in LaTeX. A PDF file can be made by printing the HTML report from the web browser.
Value
The name of the file, invisibly.
Examples
spec <- qdm_endpoint("binary") |>
qdm_sample_size(n_t = 12, n_c = 12) |>
qdm_prior(prior_t = prior_beta(0.5, 0.5),
prior_c = prior_beta(0.5, 0.5)) |>
qdm_criterion(criterion_posterior(theta_tv = 0.2, theta_mav = 0.1,
gamma_go = 0.5, gamma_nogo = 0.8))
# Text report of the operating characteristics with the R code of the
# design, printed in the console
spec |>
qdm_oc(data.frame(pi_t = c(0.3, 0.5), pi_c = 0.3)) |>
show_report(file_type = "text", open = TRUE, code = TRUE)
# HTML report of a decision in a temporary file, which is opened when R
# is used interactively
path <- spec |>
qdm_decide(data_t = data_binary(12, 9), data_c = data_binary(12, 4)) |>
show_report()