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]  9 12  6  9  9  6  9  6 12 12
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     3     3     3     0     0
#>  2     3     3     6     0     0
#>  3     3     3     0     0     0
#>  4     3     6     0     0     0
#>  5     6     3     0     0     0
#>  6     6     0     0     0     0
#>  7     3     6     0     0     0
#>  8     3     3     0     0     0
#>  9     3     6     3     0     0
#> 10     6     6     0     0     0
sims %>% tox_at_dose()
#> # A tibble: 10 × 5
#>      `1`   `2`   `3`   `4`   `5`
#>    <int> <int> <int> <int> <int>
#>  1     0     0     2     0     0
#>  2     0     0     3     0     0
#>  3     0     2     0     0     0
#>  4     0     2     0     0     0
#>  5     1     2     0     0     0
#>  6     2     0     0     0     0
#>  7     0     2     0     0     0
#>  8     0     3     0     0     0
#>  9     0     1     2     0     0
#> 10     1     2     0     0     0
sims %>% num_tox()
#>  [1] 2 3 2 2 3 2 2 3 3 3
sims %>% recommended_dose()
#>  [1]  2  2  1  1  1 NA  1  1  2  1
sims %>% prob_administer()
#>         1         2         3         4         5 
#> 0.4333333 0.4333333 0.1333333 0.0000000 0.0000000 
sims %>% prob_recommend()
#> NoDose      1      2      3      4      5 
#>    0.1    0.6    0.3    0.0    0.0    0.0 
sims %>% trial_duration()
#>  [1]  4.2 11.9  5.2  9.4  9.1  3.1  9.0  3.7 14.8 17.0

# Access the list of model fits for the ith simulated trial using:
i <- 1
sims$fits[[i]]
#> [[1]]
#> [[1]]$.depth
#> [1] 4
#> 
#> [[1]]$time
#> [1] 4.2
#> 
#> [[1]]$fit
#> Patient-level data:
#> # A tibble: 9 × 4
#>   Patient Cohort  Dose   Tox
#>     <int>  <int> <int> <int>
#> 1       1      1     1     0
#> 2       2      1     1     0
#> 3       3      1     1     0
#> 4       4      2     2     0
#> 5       5      2     2     0
#> 6       6      2     2     0
#> 7       7      3     3     0
#> 8       8      3     3     1
#> 9       9      3     3     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          0     3            0                NA              NA TRUE      
#> 3 2          0     3            0                NA              NA TRUE      
#> 4 3          2     3            0.667            NA              NA FALSE     
#> 5 4          0     0          NaN                NA              NA FALSE     
#> 6 5          0     0          NaN                NA              NA FALSE     
#> # ℹ 1 more variable: recommended <lgl>
#> 
#> The model advocates stopping and recommending dose 2.
#> 
#> 
# and the jth model fit for the ith simulated trial using:
j <- 1
sims$fits[[i]][[j]]
#> $.depth
#> [1] 4
#> 
#> $time
#> [1] 4.2
#> 
#> $fit
#> Patient-level data:
#> # A tibble: 9 × 4
#>   Patient Cohort  Dose   Tox
#>     <int>  <int> <int> <int>
#> 1       1      1     1     0
#> 2       2      1     1     0
#> 3       3      1     1     0
#> 4       4      2     2     0
#> 5       5      2     2     0
#> 6       6      2     2     0
#> 7       7      3     3     0
#> 8       8      3     3     1
#> 9       9      3     3     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          0     3            0                NA              NA TRUE      
#> 3 2          0     3            0                NA              NA TRUE      
#> 4 3          2     3            0.667            NA              NA FALSE     
#> 5 4          0     0          NaN                NA              NA FALSE     
#> 6 5          0     0          NaN                NA              NA FALSE     
#> # ℹ 1 more variable: recommended <lgl>
#> 
#> The model advocates stopping and recommending dose 2.
#> 
# and so on.