Get samples of the probability of toxicity. For instance, a Bayesian approach that supports sampling would be expected to return posterior samples of the probability of toxicity. If this class does not support sampling, this function will raise an error. You can check whether this class supports sampling by calling supports_sampling.

Get samples of the probability of efficacy For instance, a Bayesian approach that supports sampling would be expected to return posterior samples of the probability of toxicity. If this class does not support sampling, this function will raise an error. You can check whether this class supports sampling by calling supports_sampling.

prob_tox_samples(x, tall = FALSE, ...)

prob_eff_samples(x, tall = FALSE, ...)

Arguments

x

Object of type selector

tall

logical, if FALSE, a wide data-frame is returned with columns pertaining to the doses and column names the dose indices. If TRUE, a tall data-frame is returned with data for all doses stacked vertically. In this mode, column names will include dose and prob_eff.

...

arguments passed to other methods

Value

data-frame like object

data-frame like object

Examples

# CRM example
skeleton <- c(0.05, 0.1, 0.25, 0.4, 0.6)
target <- 0.25
outcomes <- '1NNN 2NTN'
fit <- get_dfcrm(skeleton = skeleton, target = target) %>% fit(outcomes)
fit %>% prob_tox_samples()
#> # A tibble: 4,000 × 6
#>    .draw      `1`     `2`    `3`    `4`   `5`
#>    <chr>    <dbl>   <dbl>  <dbl>  <dbl> <dbl>
#>  1 1     0.0300   0.0675  0.197  0.342  0.550
#>  2 2     0.0154   0.0405  0.145  0.279  0.491
#>  3 3     0.0187   0.0469  0.158  0.296  0.507
#>  4 4     0.435    0.528   0.681  0.775  0.868
#>  5 5     0.126    0.203   0.383  0.530  0.702
#>  6 6     0.0599   0.115   0.272  0.423  0.619
#>  7 7     0.000380 0.00235 0.0261 0.0899 0.261
#>  8 8     0.0411   0.0861  0.228  0.377  0.580
#>  9 9     0.219    0.311   0.495  0.628  0.772
#> 10 10    0.00602  0.0196  0.0938 0.209  0.418
#> # ℹ 3,990 more rows
fit %>% prob_tox_samples(tall = TRUE)
#> # A tibble: 20,000 × 3
#>    .draw dose  prob_tox
#>    <chr> <chr>    <dbl>
#>  1 1     1       0.559 
#>  2 2     1       0.0318
#>  3 3     1       0.146 
#>  4 4     1       0.0304
#>  5 5     1       0.0897
#>  6 6     1       0.0986
#>  7 7     1       0.154 
#>  8 8     1       0.230 
#>  9 9     1       0.358 
#> 10 10    1       0.551 
#> # ℹ 19,990 more rows
efftox_priors <- trialr::efftox_priors
p <- efftox_priors(alpha_mean = -7.9593, alpha_sd = 3.5487,
                   beta_mean = 1.5482, beta_sd = 3.5018,
                   gamma_mean = 0.7367, gamma_sd = 2.5423,
                   zeta_mean = 3.4181, zeta_sd = 2.4406,
                   eta_mean = 0, eta_sd = 0.2,
                   psi_mean = 0, psi_sd = 1)
real_doses = c(1.0, 2.0, 4.0, 6.6, 10.0)
model <- get_trialr_efftox(real_doses = real_doses,
                           efficacy_hurdle = 0.5, toxicity_hurdle = 0.3,
                           p_e = 0.1, p_t = 0.1,
                           eff0 = 0.5, tox1 = 0.65,
                           eff_star = 0.7, tox_star = 0.25,
                           priors = p, iter = 1000, chains = 1, seed = 2020)
x <- model %>% fit('1N 2E 3B')
prob_tox_samples(x, tall = TRUE)
#> # A tibble: 2,500 × 3
#>    .draw dose       prob_tox
#>    <chr> <chr>         <dbl>
#>  1 1     1     0.000167     
#>  2 2     1     0.00743      
#>  3 3     1     0.111        
#>  4 4     1     0.0000232    
#>  5 5     1     0.152        
#>  6 6     1     0.979        
#>  7 7     1     0.00000000784
#>  8 8     1     0.117        
#>  9 9     1     0.229        
#> 10 10    1     0.0000211    
#> # ℹ 2,490 more rows