Skip to contents

obtainDesign is essentially a wrapper for calls to createGrid and augmentGrid followed by some simple filtering of the candidate designs to identify the optimal and minimax designs.

Usage

obtainDesign(
  grid = NULL,
  p0 = NA,
  p1 = NA,
  alpha = ifelse(is.null(grid), 0.05, NA),
  beta = ifelse(is.null(grid), 0.1, NA),
  fullGrid = FALSE,
  ...
)

Arguments

grid

Optional. A tibble created by createGrid. If NULL, then p0, p1, alpha and beta must be specified and createGrid is called to generate the required grid. If not NULL then p0, p1, alpha and beta are ignored

p0

the response rate under the null hypothesis

p1

the response rate under the alternate hypothesis

alpha

the desired (one-sided) type 1 error rate

beta

the desired type 2 error rate

fullGrid

should the full grid of all possible designs be returned, or simply the optimal and minimax solutions? For a Mander and Thompson design, optimal and minimax designs are returned for both the null and alternate hypotheses. See Usage Notes below.

...

passed to `createGrid` or `augmentGrid`. In particular mander=TRUE for a Mander & Thompson design or mander=FALSE for a Simon's 2-stage design.

Value

a tibble created by createGrid. If fullGrid == FALSE the table contains an additional column, Criterion indicating the type of design. Possible values for Criterion are "optimal" and "minimax" for Simon's designs and "optimalNull", "optimalAlt", "minimaxNull" and "minimaxAlt" for Mander & Thompson designs.

Usage notes

If grid is not NULL it is possible that none of the candidate designs are acceptable (that is, satisfy both the significance level and power requirements). If this is the case and fullGrid == FALSE, then an empty tibble is returned. If versbose == TRUE a warning message is also printed. If fullGrid == TRUE the full grid of all designs considered is returned. This can then be further interrogated to find optimal designs under constraints - for example with fixed stage sizes.

Examples

# \donttest{
# Standard use (Simon's 2-stage design)
createGrid(p0 = 0.05, p1 = 0.25, alpha = 0.05, beta = 0.2, mander = FALSE) %>%
  augmentGrid(parallel = FALSE) %>%
  obtainDesign()
#> # A tibble: 2 × 15
#>   nTotal nStage1 rTotal rFutility    p0    p1 Alpha  Beta  Type1 Type2 PETNull
#>    <int>   <int>  <int>     <int> <dbl> <dbl> <dbl> <dbl>  <dbl> <dbl>   <dbl>
#> 1     17       9      2         0  0.05  0.25  0.05   0.2 0.0466 0.188   0.630
#> 2     16      12      2         0  0.05  0.25  0.05   0.2 0.0427 0.199   0.540
#> # ℹ 4 more variables: PETAlt <dbl>, AveSizeNull <dbl>, AveSizeAlt <dbl>,
#> #   Criterion <chr>
# Constrained stage sizes
createGrid(p0 = 0.25, p1 = 0.45, alpha = 0.05, beta = 0.2) %>%
  dplyr::filter(nStage1 == 8) %>%
  augmentGrid(parallel = FALSE) %>%
  obtainDesign()
#> # A tibble: 4 × 16
#>   nTotal nStage1 rTotal rFutility rSuccess    p0    p1 Alpha  Beta  Type1 Type2
#>    <int>   <int>  <int>     <int>    <int> <dbl> <dbl> <dbl> <dbl>  <dbl> <dbl>
#> 1     39       8     14         1        5  0.25  0.45  0.05   0.2 0.0430 0.196
#> 2     36       8     13         0        5  0.25  0.45  0.05   0.2 0.0482 0.184
#> 3     36       8     13         0        5  0.25  0.45  0.05   0.2 0.0482 0.184
#> 4     36       8     13         0        5  0.25  0.45  0.05   0.2 0.0482 0.184
#> # ℹ 5 more variables: PETNull <dbl>, PETAlt <dbl>, AveSizeNull <dbl>,
#> #   AveSizeAlt <dbl>, Criterion <chr>
# }