This class encapsulates that many notional or virtual trials can be simulated. Each recommends a dose (or doses), keeps track of how many patients have been treated at what doses, what toxicity outcomes have been seen, and whether a trial advocates continuing, etc. We run simulations to learn about the operating characteristics of a trial design.

Computationally, the simulations class supports much of the same interface as selector, and a little more. Thus, many of the same generic functions are supported - see Examples. However, compared to selectors, the returned objects reflect that there are many trials instead of one, e.g. num_patients(sims), returns as an integer vector the number of patients used in the simulated trials.

simulations(fits, true_prob_tox, true_prob_eff = NULL, ...)

Arguments

fits

Simulated model fits, arranged as list of lists.

true_prob_tox

vector of true toxicity probabilities

true_prob_eff

vector of true efficacy probabilities, optionally NULL if efficacy not analysed.

...

Extra args

Value

list with slots: fits containing model fits; and true_prob_tox, contianing the assumed true probability of toxicity.

Examples


# Simulate performance of the 3+3 design:
true_prob_tox <- c(0.12, 0.27, 0.44, 0.53, 0.57)
sims <- get_three_plus_three(num_doses = 5) %>%
  simulate_trials(num_sims = 10, true_prob_tox = true_prob_tox)
# The returned object has type 'simulations'. The supported interface is:
sims %>% num_patients()
#>  [1] 18  9  9  9 15 15  6  6 12  9
sims %>% num_doses()
#> [1] 5
sims %>% dose_indices()
#> [1] 1 2 3 4 5
sims %>% n_at_dose()
#> # A tibble: 10 × 5
#>      `1`   `2`   `3`   `4`   `5`
#>    <int> <int> <int> <int> <int>
#>  1     6     6     3     3     0
#>  2     3     6     0     0     0
#>  3     3     3     3     0     0
#>  4     3     6     0     0     0
#>  5     3     3     3     6     0
#>  6     3     6     6     0     0
#>  7     3     3     0     0     0
#>  8     3     3     0     0     0
#>  9     6     6     0     0     0
#> 10     3     3     3     0     0
sims %>% tox_at_dose()
#> # A tibble: 10 × 5
#>      `1`   `2`   `3`   `4`   `5`
#>    <int> <int> <int> <int> <int>
#>  1     1     1     0     3     0
#>  2     0     2     0     0     0
#>  3     0     0     2     0     0
#>  4     0     2     0     0     0
#>  5     0     0     0     2     0
#>  6     0     1     2     0     0
#>  7     0     2     0     0     0
#>  8     0     2     0     0     0
#>  9     1     3     0     0     0
#> 10     0     0     2     0     0
sims %>% num_tox()
#>  [1] 5 2 2 2 2 3 2 2 4 2
sims %>% recommended_dose()
#>  [1] 3 1 2 1 3 2 1 1 1 2
sims %>% prob_administer()
#>          1          2          3          4          5 
#> 0.33333333 0.41666667 0.16666667 0.08333333 0.00000000 
sims %>% prob_recommend()
#> NoDose      1      2      3      4      5 
#>    0.0    0.5    0.3    0.2    0.0    0.0 
sims %>% trial_duration()
#>  [1] 25.738788  9.265536  8.813159  6.271476 20.945065 28.050702  3.155975
#>  [8]  4.888645  9.484636  5.244005

# Access the list of model fits for the ith simulated trial using:
i <- 1
sims$fits[[i]]
#> [[1]]
#> [[1]]$.depth
#> [1] 7
#> 
#> [[1]]$time
#> [1] 25.73879
#> 
#> [[1]]$fit
#> Patient-level data:
#> # A tibble: 18 × 4
#>    Patient Cohort  Dose   Tox
#>      <int>  <int> <int> <int>
#>  1       1      1     1     0
#>  2       2      1     1     0
#>  3       3      1     1     1
#>  4       4      2     1     0
#>  5       5      2     1     0
#>  6       6      2     1     0
#>  7       7      3     2     1
#>  8       8      3     2     0
#>  9       9      3     2     0
#> 10      10      4     2     0
#> 11      11      4     2     0
#> 12      12      4     2     0
#> 13      13      5     3     0
#> 14      14      5     3     0
#> 15      15      5     3     0
#> 16      16      6     4     1
#> 17      17      6     4     1
#> 18      18      6     4     1
#> 
#> Dose-level data:
#> # A tibble: 6 × 8
#>   dose     tox     n empiric_tox_rate mean_prob_tox median_prob_tox admissible
#>   <ord>  <dbl> <dbl>            <dbl>         <dbl>           <dbl> <lgl>     
#> 1 NoDose     0     0            0                 0               0 TRUE      
#> 2 1          1     6            0.167            NA              NA TRUE      
#> 3 2          1     6            0.167            NA              NA TRUE      
#> 4 3          0     3            0                NA              NA TRUE      
#> 5 4          3     3            1                NA              NA FALSE     
#> 6 5          0     0          NaN                NA              NA FALSE     
#> # ℹ 1 more variable: recommended <lgl>
#> 
#> The model advocates stopping and recommending dose 3.
#> 
#> 
# and the jth model fit for the ith simulated trial using:
j <- 1
sims$fits[[i]][[j]]
#> $.depth
#> [1] 7
#> 
#> $time
#> [1] 25.73879
#> 
#> $fit
#> Patient-level data:
#> # A tibble: 18 × 4
#>    Patient Cohort  Dose   Tox
#>      <int>  <int> <int> <int>
#>  1       1      1     1     0
#>  2       2      1     1     0
#>  3       3      1     1     1
#>  4       4      2     1     0
#>  5       5      2     1     0
#>  6       6      2     1     0
#>  7       7      3     2     1
#>  8       8      3     2     0
#>  9       9      3     2     0
#> 10      10      4     2     0
#> 11      11      4     2     0
#> 12      12      4     2     0
#> 13      13      5     3     0
#> 14      14      5     3     0
#> 15      15      5     3     0
#> 16      16      6     4     1
#> 17      17      6     4     1
#> 18      18      6     4     1
#> 
#> Dose-level data:
#> # A tibble: 6 × 8
#>   dose     tox     n empiric_tox_rate mean_prob_tox median_prob_tox admissible
#>   <ord>  <dbl> <dbl>            <dbl>         <dbl>           <dbl> <lgl>     
#> 1 NoDose     0     0            0                 0               0 TRUE      
#> 2 1          1     6            0.167            NA              NA TRUE      
#> 3 2          1     6            0.167            NA              NA TRUE      
#> 4 3          0     3            0                NA              NA TRUE      
#> 5 4          3     3            1                NA              NA FALSE     
#> 6 5          0     0          NaN                NA              NA FALSE     
#> # ℹ 1 more variable: recommended <lgl>
#> 
#> The model advocates stopping and recommending dose 3.
#> 
# and so on.