Skip to contents

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 design_binary, design_continuous, design_binary2, design_continuous2 or design_tte, or a design specification started by qdm_endpoint. Its sample sizes are replaced by the candidates.

scenario_go, scenario_nogo, target_go, target_nogo

As in qdm_calibrate.

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 n_t or a single number for all, or NULL (the default) for as many as in the treatment group with a concurrent control group and 0 without one. A ratio of allocation is given by n_c, for example n_c = n_t / 2 for even n_t.

nsim, seed

As in qdm_oc.

Value

An object of class "qdm_n_search": a list with elements

n_t, n_c

The smallest candidate that meets the targets (NA if none does).

n_t_stable, n_c_stable

The smallest candidate from which every larger candidate also meets the targets (NA if the largest candidate does not meet them).

prob_go, prob_nogo

The probabilities that the Go criterion is met under scenario_go and that the NoGo criterion is met under scenario_nogo, for n_t and n_c.

target_go, target_nogo

The targets.

curve

A data frame with the columns n_t, n_c, prob_go, prob_nogo and met (whether both targets are met), one row per candidate.

oc

A data frame of the decision probabilities with n_t and n_c under the two scenarios (NULL if no candidate meets the targets).

design

The design with n_t and n_c (NULL if no candidate meets the targets).

scenario_go, scenario_nogo, method

The scenarios and the method of computation.

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.

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
#> Search for the sample size (exact enumeration of the outcomes)
#>   Targets: P(Go criterion met | scenario_go) <= 0.1 and P(NoGo criterion met | scenario_nogo) <= 0.1
#>   Smallest candidate that meets the targets: n_t = 20, n_c = 20
#>     P(Go criterion met | scenario_go) = 0.07267
#>     P(NoGo criterion met | scenario_nogo) = 0.01676
#> Probabilities for the candidate sample sizes
#>  n_t n_c prob_go prob_nogo   met
#>    6   6 0.18844  0.083872 FALSE
#>    8   8 0.22223  0.065947 FALSE
#>   10  10 0.12644  0.052145 FALSE
#>   12  12 0.14854  0.041368 FALSE
#>   14  14 0.16612  0.032875 FALSE
#>   16  16 0.10285  0.026211 FALSE
#>   18  18 0.11655  0.020935 FALSE
#>   20  20 0.07267  0.016762  TRUE
#>   22  22 0.08263  0.013449  TRUE
#>   24  24 0.09203  0.010812  TRUE
#>   26  26 0.05929  0.008708  TRUE
#>   28  28 0.06637  0.007121  TRUE
#>   30  30 0.04292  0.005780  TRUE
#> Decision probabilities with the chosen sample size
#>       scenario pi_t pi_c      Go    NoGo   Gray Miss
#>    scenario_go  0.4  0.4 0.07267 0.43615 0.4912    0
#>  scenario_nogo  0.7  0.4 0.69555 0.01676 0.2877    0
plot(res)

res$design
#> Design: one binary endpoint
#>   Treatment: n = 20, prior Beta(a = 0.5, b = 0.5)
#>   Control: concurrent, n = 20, prior Beta(a = 0.5, b = 0.5)
#> Posterior probability criterion
#>   Go:   P(theta > 0.2 | data) >= 0.5
#>   NoGo: P(theta <= 0.1 | data) >= 0.8