Skip to contents

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_size

n_t and n_c;

qdm_prior

prior_t and prior_c;

qdm_criterion

criterion;

qdm_external

external_t and external_c;

qdm_control

hypothetical_c and fixed_c;

qdm_tte

milestone, effect, conduct and conduct_future (time-to-event endpoint);

qdm_computation

method, nMC and enumerate.

qdm_build creates the design with the design_*() function of the endpoint.

Usage

qdm_endpoint(endpoint)

Arguments

endpoint

Type of endpoint: "binary" (one binary endpoint, design_binary), "continuous" (one continuous endpoint, design_continuous), "binary2" (two binary endpoints, design_binary2), "continuous2" (two continuous endpoints, design_continuous2) or "tte" (one time-to-event endpoint, design_tte).

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).

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.

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
#> Design specification (complete):
#> Design: one binary endpoint
#>   Treatment: n = 12, prior Beta(a = 0.5, b = 0.5)
#>   Control: concurrent, n = 12, 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

# 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)
#> [1] TRUE

# 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))
#> Decision: Go
#>   Go:   P(theta > 0.2 | data) = 0.8517 (threshold 0.5, met)
#>   NoGo: P(theta <= 0.1 | data) = 0.05935 (threshold 0.8, not met)
#> Posterior distributions
#>   Treatment: Beta(a = 9.5, b = 3.5)
#>   Control:   Beta(a = 4.5, b = 8.5)