## E X A M P L E 1: Update on treatment effect, flat prior
##
## A. Trial Design:
## ----------------
## A.1 2 stages (interim + final):
## --> nr.stages = 2
## A.2 10 patients per arms and stages. (total 2*2*10 = 40 patients)
## --> patients = 10
## A.3 Sigma in both arms = 10
## --> sigma = 10
## A.3 Criteria:
## stop for success, if P( delta > 0 | data ) >= 0.8
## AND P( delta > 7 | data ) >= 0.5
## --> criteria.success = c(0,0.8,7,0.5)
## stop for futility, if P( delta < 2 | data ) >= 0.8
## --> criteria.futility = c(2,0.8)
## A.4 Prior:
## --> prior = "non-informative"
design1 <- gsbDesign(nr.stages = 2,
patients = 10,
sigma = 10,
criteria.success = c(0,0.8, 7, 0.5),
criteria.futility = c(2,0.8),
prior.difference = "non-informative")
design1
## B. Simulation Settings
## ----------------------
## B.1 True treatment effects to be evaluated = seq(-10,20,60)
## --> truth = c(-10,20,60)
## B.2 Bayesian update on treatment effect delta (= treatment - control)
## --> type.update = "treatment effect"
simulation1 <- gsbSimulation(truth=c(-10,20,60),
type.update="treatment effect")
simulation1
## C.1 Calculate the operating characteristics
x1 <- gsb(design=design1, simulation=simulation1)
x1
## D.1 Table the probabilities of success
t1.1 <- tab(x1, "success", digits=2)
t1.1
## D.2 Table the cumulative probabilities of futility at delta = c(-5,0,5.57)
## (for 5.57 a linear interpolation is used.)
t1.2 <- tab(x1, "cumulative futility", atDelta = c(-5,0,5.57), digits=5)
t1.2
## D.3 Table the expected sample size (digits == 0 --> ceiling)
t1.3 <- tab(x1, "sample size", atDelta= c(-5,0,5,16), digits=0)
t1.3
## E.1 Plot the operating characteristics
plot(x1)
## E.2 Plot the operating characteristics
plot(x1,"cumulative all")
## E.3 Plot the expected sample size
plot(x1, what="sample size")
## F.1 Boundaries / criteria
x1$boundary
plot(x1, what="boundary")
plot(x1, what="std.boundary")
## E X A M P L E 2: Update on treatment effect, informative prior
##
## A. Trial design:
## ----------------
## A.1 3 stages (interims + final):
## --> nr.stages = 3
## A.2 10 patients per stage in control arm
## 15 patients per stage in treatment arm
## (i.e. total 3 * ( 10 + 15 ) = 75 patients)
## --> patients = c(10,15)
## A.3 Sigma in control arm = 9, sigma in treatment arm = 12
## --> sigma = c(9,12)
## A.3 Criteria:
## stop for success, if P( delta > 0 | data ) >= 0.8
## AND P( delta > 7 | data ) >= 0.5
## --> criteria.success = c(0,0.8,7,0.5)
## not stop for futility, i.e. no futility criteria
## --> criteria.futility = NA
## A.4 Prior on difference:
## prior difference = 3
## informative prior equivalent to:
## 5 patients in control arm; 2 patients in treatment arm
## --> prior = c(3,5,2)
design2a <- gsbDesign(nr.stages = 3,
patients = c(10,15),
sigma=c(9,12),
criteria.success = c(0,0.8,7,0.5),
criteria.futility = NA,
prior.diff = c(3,5,2))
design2a
## A similar design with 3 success criteria can be specified as follows
## A.3 criteria:
## Stage 1: stop for success, if P( delta > 0 | data ) >= 0.8
## AND if P( delta > 10 | data ) >= 0.5
## AND if P( delta > 14 | data ) >= 0.4
## Stage 2: stop for success, if P( delta > 0 | data ) >= 0.8
## AND if P( delta > 9 | data ) >= 0.5
## AND if P( delta > 13 | data ) >= 0.4
## Stage 3: stop for success, if P( delta > 0 | data ) >= 0.8
## AND if P( delta > 7 | data ) >= 0.5
## AND if P( delta > 12 | data ) >= 0.4
## --> criteria.success = rbind(c(0,0.8, 10,0.5, 14,0.4),
## c(0,0.8, 9,0.5, 13,0.4),
## c(0,0.8, 7,0.5, 12,0.4))
design2b <- gsbDesign(nr.stages = 3,
patients = c(10,15),
sigma = c(9,12),
criteria.success = rbind(c(0,0.8, 10,0.5, 14,0.4),
c(0,0.8, 9,0.5, 13,0.4),
c(0,0.8, 7,0.5, 12,0.4)),
criteria.futility = NA,
prior.diff = c(3,5,2))
design2b
## B. Simulation Settings
## ----------------------
## B.1 True treatment effects to be evaluated from -5 to 30
## --> truth = -5:30
## B.2 To enter the values in this format set grid.type = "manually"
## --> grid.type = "manually"
## B.2 Bayesian update on treatment effect delta (treatment - control)
## --> type.update = "treatment effect"
simulation2 <- gsbSimulation(truth = -5:30,
grid.type ="manually",
type.update = "treatment effect")
simulation2
## C. Calculate the operating characteristics
x2a <- gsb(design = design2a, simulation = simulation2)
x2b <- gsb(design = design2b, simulation = simulation2)
x2a
x2b
## D. Table the cumulative probabilities of success of 'design2b'
## at delta = c(-5,0,5.57). For 5.57 a linear interpolation is used.
t2b <- tab(x2b, "cumulative success", atDelta = c(-5,0,5.57), digits=5)
t2b
## E. Plot the operating characteristics of 'design2a' and 'design2b'
plot(x2a)
plot(x2b)
plot(x2a,"cumulative all")
## F.1 Boundaries / criteria of 'design2b'
x2b$boundary
plot(x2b, what="boundary")
plot(x2b, what="std.boundary")
# \donttest{
## E X A M P L E 3: Update on treatment effect, informative prior
##
## A. Trial Design
## ---------------
## A.1 3 stages (interims + final):
## --> nr.stages = 3
## A.2 Patients:
## Stage 1: 10 patients in control arm; 15 patients in treatment arm
## Stage 2: 20 patients in control arm; 30 patients in treatment arm
## Stage 3: 30 patients in control arm; 45 patients in treatment arm
## --> patients = rbind(c(10,15),c(20,30),c(30,45))
## A.3 Sigma in control arm = 9 ; in treatment arm = 12
## --> sigma = c(9,12)
## A.4 Success criteria for all stages:
## stop for success, if P( delta > 0 | data ) >= 0.8
## AND P( delta > 7 | data ) >= 0.5
## --> criteria.success = c(0,0.8,7,0.5)
## A.5 Futility criteria:
## Stage 1: no futility criteria
## Stage 2: stop for futility, if P( delta < 2 | data ) >= 0.8
## Stage 3: stop for futility, if P( delta < 2 | data ) >= 0.8
## --> criteria.futility = rbind(c(NA,NA),c(2,0.8),c(2,0.8))
## A.6 Prior on treatment effect:
## difference = 3;
## informative prior equivalent to:
## 2 placebo patient; 1 treatment patient
## --> prior.difference = c(3,2,1)
design3 <- gsbDesign(nr.stages = 3,
patients = rbind(c(10,15),c(20,30),c(30,45)),
sigma=c(9,12),
criteria.success = c(0,0.8,7,0.5),
criteria.futility = rbind(c(NA,NA),c(2,0.8),c(2,0.8)),
prior.difference = c(3,2,1))
design3
## B. Simulation Settings
## ----------------------
## B.1 True treatment effects to be evaluated at seq(-5,20,15)
## --> truth = c(-5,20,15)
## B.2 Bayesian update on treatment effect delta (= treatment - control)
## --> type.update = "treatment effect"
## B.3 Operating characteristics are evaluated by simulation and
## numerical integration to double check the results
## --> method = "both"
## B.4 Number of simulations = 5000
## --> nr.sim = 5000
## B.5 If the number of simulated trials is smaller than 300
## during the simulation print a warning.
## --> warnings.sensitivity = 300
## B.6 A seed value is set to 13
## --> seed = 13
simulation3 <- gsbSimulation(truth = c(-5,20,15),
type.update = "treatment effect",
method = "both",
nr.sim = 5000,
warnings.sensitivity = 300,
seed = 13)
simulation3
## C. Calculate the operating characteristics
x3 <- gsb(design = design3, simulation = simulation3)
x3
## D. The summary(x3) is almost the same as print(x3) but its entries
## can be saved as list.
s3 <- summary(x3)
names(s3)
## E.1 Plot the operating characteristics
plot(x3)
## E.2 Plot the operating characteristics obtained by simulation and
## numerical integration in one plot. The lines should be identical (then
## only one line is visible)
plot(x3, "both")
plot(x3, "cumulative both")
## E X A M P L E 4 - Boundaries / Criteria
## See how the Bayesian boundaries change within 10 stages.
##
## A. Trial Design:
## ----------------
## A.1 10 stages (interims + final):
## --> nr.stages = 10
## A.2 10 patients per arm and stage. (total 2*10*10 = 200 patients)
## --> patients = 10
## A.3 sigma in both arms = 10
## --> sigma = 10
## A.3 Criteria:
## stop for success, if P( delta > 0 | data ) >= 0.8
## AND P( delta > 7 | data ) >= 0.5
## --> criteria.success = c(0,0.8,7,0.5)
## stop for futility, if P( delta < 2 | data ) >= 0.8
## --> criteria.futility = c(2,0.8)
## A.4 Prior:
## --> prior = "non-informative"
design4 <- gsbDesign(nr.stages=10,
patients=10,
sigma=10,
criteria.success=c(0,0.8, 7, 0.5),
criteria.futility=c(2,0.8),
prior.difference="non-informative")
design4
## B. Simulation Settings
## --------------------------------------------
## B.1 True treatment effects to be evaluated = seq(-10,20,60)
## --> truth = c(-10,20,60)
## B.2 Bayesian update on treatment effect delta (= treatment - control)
## --> type.update = "treatment effect"
simulation4 <- gsbSimulation(truth=c(-10,20,60),
type.update="treatment effect")
simulation4
## C. Calculate the operating characteristics
x4 <- gsb(design = design4, simulation = simulation4)
x4
## D. Boundaries / criteria
x4$boundary
plot(x4, what="boundary")
plot(x4, what="std.boundary")
## E X A M P L E 5 - Bayesian update "per arm",
##
## A. Trial Design:
## ----------------
## A.1 3 stages (interims + final):
## --> nr.stages = 3
## A.2 12 patients per stage in control arm
## 20 patients per stage in treatment arm
## (i.e. total 3 * ( 12 + 20 ) = 96 patients)
## --> patients = c(12,20)
## A.3 sigma in both arms = 10
## --> sigma = 10
## A.3 Criteria:
## stop for success, if P( delta > 0 | data ) >= 0.8
## AND P( delta > 7 | data ) >= 0.5
## --> criteria.success = c(0,0.8,7,0.5)
## stop for futility, if P( delta < 2 | data ) >= 0.8
## --> criteria.futility = c(2,0.8)
## A.4 Prior:
## informative prior equivalent to:
## 2 patients in control arm with mean = 0
## --> prior.control = c(0,2)
## 1 patient in treatment arm with mean = 7
## --> prior.treatment = c(7,1)
design5 <- gsbDesign(nr.stages=3,
patients=c(12,20),
sigma=10,
criteria.success=c(0,0.8,7,0.5),
criteria.futility=c(2,0.8),
prior.control=c(0,2),
prior.treatment=c(7,1))
design5
## B. Simulation Settings: - with table grid
## --------------------------------------------
## B.1 True control/treatment values:
## control = seq(1,5,0.5)
## treatment = seq(1,7,1)
## --> truth = list(seq(1,5,0.5),seq(1,7,1))
## B.2 Output optimized to create table
## --> grid.type = "table"
## B.3 Bayesian update per arm
## --> type.update = "per arm"
## B.4 Number of simulations = 5000 (which is low)
## --> nr.sim = 5000
## B.5 If the number of simulations is smaller than 2000
## print a warning.
## --> warnings.sensitivity = 2000
## B.6 A seed value is set to 13
## --> seed = 13
simulation5.table <- gsbSimulation(truth = list(seq(1,5,0.5), seq(1,7,1)),
grid.type = "table",
type.update = "per arm",
nr.sim = 5000,
warnings.sensitivity = 2000,
seed = 13)
simulation5.table
## The same grid can be specified manually by
simulation5.manually <- gsbSimulation(truth = as.matrix(expand.grid(seq(1,5,0.5),seq(1,7,1))),
grid.type = "manually",
type.update = "per arm",
nr.sim = 5000,
warnings.sensitivity = 2000,
seed = 13)
simulation5.manually
## To specify a grid optimized for sliced plotting with
## control values from -10 to 0 and treatment values from -10 to 25
simulation5.sliced <- gsbSimulation(truth = list(control=seq(-10,0,2), delta=seq(-10,25,4)),
grid.type = "sliced",
type.update = "per arm",
nr.sim = 5000,
warnings.sensitivity = 2000,
seed = 13)
simulation5.sliced
## To specify a grid optimized for plotting with
## control values from 1 to 5 and treatment values from 1 to 7
## with approximately 20 values enter:
simulation5.plot <- gsbSimulation(truth = c(1,5,1,7,20),
grid.type = "plot",
type.update = "per arm",
nr.sim = 5000,
warnings.sensitivity = 2000,
seed = 13)
simulation5.plot
## C. Use function gsb
x5.table <- gsb(design5,simulation5.table)
x5.sliced <- gsb(design5,simulation5.sliced)
x5.plot <- gsb(design5,simulation5.plot)
x5.table
## D. Tables
## D.1 For any grid a table in long format can be obtained
t5.1 <- tab(x5.table,"cumulative futility")
head(t5.1)
t5.2 <- tab(x5.sliced,"all")
head(t5.2)
## D.2 For the "table" grid there are additionally tables in wide format available.
t5.3 <- tab(x5.table,"success", wide=TRUE)
t5.3
## Fix a stage, e.g. stage 2, to get a matrix
t5.3[,,2]
## D.2 Set delta.control to '3' to get a matrix
t5.3["contr 3",,]
# D.3 Plot results
plot(x5.table)
plot(x5.plot)
plot(x5.sliced)
plot(x5.sliced, sliced=TRUE)
plot(x5.sliced, sliced=TRUE, range.control=c(-4,0))
plot(x5.sliced, what="success", sliced=TRUE, range.control=c(-4,0))
## the plot can differ because the number of simulations "nr.sim"
## is low and because the grids are different
plot(x5.plot,"sample size", color=FALSE)
head(tab(x5.table,"sample size"))
# }
Run the code above in your browser using DataLab