-
Notifications
You must be signed in to change notification settings - Fork 0
/
results.R
101 lines (93 loc) · 3.66 KB
/
results.R
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
library(mvtnorm)
library(ggplot2)
library(latex2exp)
source("/accelerated-approval/functions.R")
# Figure 1 of the futility boundary for the success boundary 0.01, with different correlation values
# and information fractions
alpha <- 0.025
p_S <- 0.01
r <- seq(0.1, 0.7, 0.2)
rho <- seq(-1, 1, 0.001)
scen <- expand.grid(rho = rho, r = r)
p_F <- rep(NA, nrow(scen))
for (i in 1:nrow(scen)) {
p_F[i] <- uniroot(type1_fun_alpha,
c(p_S, 1),
alpha = alpha,
r = scen$r[i],
rho = scen$rho[i],
p_S = p_S)$root
}
data <- data.frame(scen, p_F)
data$r <- factor(data$r)
ggplot(data, aes(x = rho, y = p_F, group = r)) +
geom_line(aes(linetype = r), linewidth = 1.2) +
scale_x_continuous(breaks = seq(-1, 1, 0.2),
limits = c(-1, 1),
expand = c(0.01, 0.01)) +
scale_y_continuous(breaks = c(seq(0, 1, 0.1), alpha),
minor_breaks = c(seq(0, 1, 0.1), alpha),
limits = c(0, 1),
expand = c(0.01, 0.01)) +
scale_linetype_manual(values=c("solid", "longdash", "dotdash", "dotted"))+
xlab(TeX(r'(Correlation $\rho$ between ORR and OS)')) +
ylab(TeX(r'(Futility $p$-value boundary $p_F$ for ORR)')) +
guides(linetype = guide_legend(title = paste("Information\nfraction ", TeX(r'($r$)'), " of OS"),
position = "inside")) +
theme(legend.title = element_text(size = 10),
legend.text = element_text(size = 10),
legend.position.inside = c(0.85, 0.75),
legend.key.width = unit(2, 'cm'),
axis.text = element_text(size = 10),
axis.title = element_text(size = 13))
# Table 1 of the futility boundary for the success boundary 0.01
alpha <- 0.025
p_S <- 0.01
r <- seq(0.1, 0.7, 0.1)
p_F <- r
orr_c <- 0.2
orr_t <- r
nper <- 100
orr_t_0.025 <- uniroot(orr_fun, c(0, 1), orr_c = orr_c, nper = nper, alpha = alpha)$root
for (i in 1:length(r)) {
p_F[i] <- uniroot(type1_search, c(p_S, 1), alpha = alpha, r = r[i], p_S = p_S)$root
orr_t[i] <- uniroot(orr_fun, c(0, 1), orr_c = orr_c, nper = nper, alpha = p_F[i])$root
}
rbind(r = formatC(r, format = "f", digits = 1),
p_F = formatC(p_F, format = "f", digits = 3),
diff = paste0(formatC(round((orr_t - orr_c) / (orr_t_0.025 - orr_c) *100, 0), format = "f", digits = 0), "%")
)
# Table 2 of the futility boundary for the success boundary 0.005
alpha <- 0.025
p_S <- 0.005
r <- seq(0.1, 0.7, 0.1)
p_F <- r
orr_c <- 0.2
orr_t <- r
nper <- 100
orr_t_0.025 <- uniroot(orr_fun, c(0, 1), orr_c = orr_c, nper = nper, alpha = alpha)$root
for (i in 1:length(r)) {
p_F[i] <- uniroot(type1_search, c(p_S, 1), alpha = alpha, r = r[i], p_S = p_S)$root
orr_t[i] <- uniroot(orr_fun, c(0, 1), orr_c = orr_c, nper = nper, alpha = p_F[i])$root
}
rbind(r = formatC(r, format = "f", digits = 1),
p_F = formatC(p_F, format = "f", digits = 3),
diff = paste0(formatC(round((orr_t - orr_c) / (orr_t_0.025 - orr_c) *100, 0), format = "f", digits = 0), "%")
)
# Table 2 of the futility boundary for the success boundary 0.0125
alpha <- 0.025
p_S <- 0.0125
r <- seq(0.1, 0.7, 0.1)
p_F <- r
orr_c <- 0.2
orr_t <- r
nper <- 100
orr_t_0.025 <- uniroot(orr_fun, c(0, 1), orr_c = orr_c, nper = nper, alpha = alpha)$root
for (i in 1:length(r)) {
p_F[i] <- uniroot(type1_search, c(p_S, 1), alpha = alpha, r = r[i], p_S = p_S)$root
orr_t[i] <- uniroot(orr_fun, c(0, 1), orr_c = orr_c, nper = nper, alpha = p_F[i])$root
}
rbind(r = formatC(r, format = "f", digits = 1),
p_F = formatC(p_F, format = "f", digits = 3),
diff = paste0(formatC(round((orr_t - orr_c) / (orr_t_0.025 - orr_c) *100, 0), format = "f", digits = 0), "%")
)