if (FALSE) {
target <- 0.25
skeleton <- c(0.05, 0.15, 0.25, 0.4, 0.6)
# Run DTPs for the first two cohorts of two for new a trial:
paths <- crm_dtps(skeleton = skeleton, target = target, model = 'empiric',
cohort_sizes = c(2, 2), next_dose = 3, beta_sd = 1)
length(paths) # 13
library(tibble)
df <- as_tibble(paths)
df
# Run DTPs for the next cohort of three in a trial that has already treated
# six patients, seeing some toxicity at dose-level 3:
paths2 <- crm_dtps(skeleton = skeleton, target = target, model = 'empiric',
cohort_sizes = c(3), previous_outcomes = '2NNN 3TTN',
beta_sd = 1)
length(paths2) # 5
as_tibble(paths2)
# We see that de-escalation to dose-level 2 should occur now, and that any
# further toxicity will result in advice for further de-escalation to
# dose-level 1.
# An example with a custom dose selection function
paths3 <- crm_dtps(skeleton = skeleton, target = target, model = 'empiric',
cohort_sizes = c(3, 3), previous_outcomes = '2NN 3TN',
next_dose = 2, beta_sd = 1,
user_dose_func = function(x) {
careful_escalation(x, tox_threshold = target + 0.1,
certainty_threshold = 0.7)
}, seed = 123, refresh = 0)
spread_paths(as_tibble(paths3) %>% select(-fit, -parent_fit, -dose_index))
# Stopping is recommended when the dose selection function returns NA.
}
Run the code above in your browser using DataLab