Skip to contents

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.

Usage

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  9  6 18  9 12  9 18  9  6
sims %>% num_doses()
#> [1] 5
sims %>% dose_indices()
#> [1] 1 2 3 4 5
sims %>% dose_strings()
#> [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     6     0     0     0
#>  2     3     3     3     0     0
#>  3     6     0     0     0     0
#>  4     6     6     3     3     0
#>  5     3     3     3     0     0
#>  6     3     3     6     0     0
#>  7     6     3     0     0     0
#>  8     3     6     3     6     0
#>  9     3     6     0     0     0
#> 10     6     0     0     0     0
sims %>% tox_at_dose()
#> # A tibble: 10 × 5
#>      `1`   `2`   `3`   `4`   `5`
#>    <int> <int> <int> <int> <int>
#>  1     0     2     0     0     0
#>  2     0     0     2     0     0
#>  3     2     0     0     0     0
#>  4     1     1     0     3     0
#>  5     0     0     3     0     0
#>  6     0     0     3     0     0
#>  7     1     2     0     0     0
#>  8     0     1     0     2     0
#>  9     0     2     0     0     0
#> 10     3     0     0     0     0
sims %>% num_tox()
#>  [1] 2 2 2 5 3 3 3 3 2 3
sims %>% recommended_dose()
#>  [1]  1  2 NA  3  2  2  1  3  1 NA
sims %>% prob_administer()
#>          1          2          3          4          5 
#> 0.40000000 0.34285714 0.17142857 0.08571429 0.00000000 
sims %>% prob_recommend()
#> NoDose      1      2      3      4      5 
#>    0.2    0.3    0.3    0.2    0.0    0.0 
sims %>% trial_duration()
#>  [1] 14.408821  3.488594  8.571498 14.619680  8.483619 16.221354  7.956283
#>  [8] 16.064913 10.241924  6.853798

# 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] 14.40882
#> 
#> [[1]]$fit
#> Patient-level data:
#> # A tibble: 9 × 5
#>   Patient Cohort  Dose   Tox Weight
#>     <int>  <int> <int> <int>  <dbl>
#> 1       1      1     1     0      1
#> 2       2      1     1     0      1
#> 3       3      1     1     0      1
#> 4       4      2     2     0      1
#> 5       5      2     2     1      1
#> 6       6      2     2     0      1
#> 7       7      3     2     1      1
#> 8       8      3     2     0      1
#> 9       9      3     2     0      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          2     6            0.333            NA              NA FALSE     
#> 4 3          0     0          NaN                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 1.
#> 
#> 
# and the jth model fit for the ith simulated trial using:
j <- 1
sims$fits[[i]][[j]]
#> $.depth
#> [1] 4
#> 
#> $time
#> [1] 14.40882
#> 
#> $fit
#> Patient-level data:
#> # A tibble: 9 × 5
#>   Patient Cohort  Dose   Tox Weight
#>     <int>  <int> <int> <int>  <dbl>
#> 1       1      1     1     0      1
#> 2       2      1     1     0      1
#> 3       3      1     1     0      1
#> 4       4      2     2     0      1
#> 5       5      2     2     1      1
#> 6       6      2     2     0      1
#> 7       7      3     2     1      1
#> 8       8      3     2     0      1
#> 9       9      3     2     0      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          2     6            0.333            NA              NA FALSE     
#> 4 3          0     0          NaN                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 1.
#> 
# and so on.