-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathDesign-method-simulate-DesignGrouped.R
More file actions
78 lines (71 loc) · 1.99 KB
/
Design-method-simulate-DesignGrouped.R
File metadata and controls
78 lines (71 loc) · 1.99 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# Assemble ingredients for our group design.
my_stopping <- StoppingTargetProb(target = c(0.2, 0.35), prob = 0.5) |
StoppingMinPatients(10) |
StoppingMissingDose()
my_increments <- IncrementsDoseLevels(levels = 3L)
my_next_best <- NextBestNCRM(
target = c(0.2, 0.3),
overdose = c(0.3, 1),
max_overdose_prob = 0.3
)
my_cohort_size <- CohortSizeConst(3)
empty_data <- Data(
doseGrid = c(0.1, 0.5, 1.5, 3, 6, seq(from = 10, to = 80, by = 2))
)
my_model <- LogisticLogNormalGrouped(
mean = c(-4, -4, -4, -4),
cov = diag(rep(6, 4)),
ref_dose = 0.1
)
# Put together the design. Note that if we only specify the mono arm,
# then the combo arm is having the same settings.
my_design <- DesignGrouped(
model = my_model,
mono = Design(
model = my_model,
stopping = my_stopping,
increments = my_increments,
nextBest = my_next_best,
cohort_size = my_cohort_size,
data = empty_data,
startingDose = 0.1
),
first_cohort_mono_only = TRUE,
same_dose_for_all = TRUE
)
# Set up a realistic simulation scenario.
my_truth <- function(x) plogis(-4 + 0.2 * log(x / 0.1))
my_combo_truth <- function(x) plogis(-4 + 0.5 * log(x / 0.1))
matplot(
x = empty_data@doseGrid,
y = cbind(
mono = my_truth(empty_data@doseGrid),
combo = my_combo_truth(empty_data@doseGrid)
),
type = "l",
ylab = "true DLT prob",
xlab = "dose"
)
legend("topright", c("mono", "combo"), lty = c(1, 2), col = c(1, 2))
# Start the simulations.
set.seed(123)
\donttest{
my_sims <- simulate(
my_design,
nsim = 1, # This should be at least 100 in actual applications.
seed = 123,
truth = my_truth,
combo_truth = my_combo_truth
)
# Looking at the summary of the simulations:
mono_sims_sum <- summary(my_sims$mono, truth = my_truth)
combo_sims_sum <- summary(my_sims$combo, truth = my_combo_truth)
mono_sims_sum
combo_sims_sum
plot(mono_sims_sum)
plot(combo_sims_sum)
# Looking at specific simulated trials:
trial_index <- 1
plot(my_sims$mono@data[[trial_index]])
plot(my_sims$combo@data[[trial_index]])
}