-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path.Rhistory
512 lines (512 loc) · 23.3 KB
/
.Rhistory
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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
rho,
rho_type='Spearman',
followup_time=1,
alpha=0.05,
power=0.80 ,
ss_formula='schoenfeld')
plot_tte(p0_e1,
p0_e2,
HR_e1,
HR_e2,
beta_e1,
beta_e2,
case,
copula = 'Frank',
rho,
rho_type='Spearman',
followup_time=1,
alpha=0.05,
power=0.80 ,
ss_formula='schoenfeld')
plot_tte(p0_e1,
p0_e2,
HR_e1,
HR_e2,
beta_e1,
beta_e2,
case,
copula = 'Frank',
rho,
rho_type='Spearman',
followup_time=1,
alpha=0.05,
power=0.80 ,
ss_formula='schoenfeld')
plot_surv <- surv_tte(p0_e1, p0_e2, HR_e1, HR_e2, beta_e1=beta_e1, beta_e2=beta_e2, case=case,
copula = copula, rho=rho, rho_type=rho_type,
followup_time=followup_time,
plot_res=FALSE, plot_save =TRUE)$gg_object
plot_surv
install.packages("CompAREdesign")
install.packages("CompAREdesign", dependencies = TRUE)
sessionInfo()
remove.packages("CompAREdesign")
plot_tte(p0_e1, p0_e2, HR_e1, HR_e2, beta_e1, beta_e2, case,
copula = 'Frank', rho, rho_type='Spearman',
followup_time=1,
alpha=0.05, power=0.80 ,ss_formula='schoenfeld')
## Probabilities of observing the event in control arm during follow-up
p0_e1 <- 0.59 # Death
p0_e2 <- 0.74 # Disease Progression
## Effect size (Cause specific hazard ratios) for each endpoint
HR_e1 <- 0.91 # Death
HR_e2 <- 0.77 # Disease Progression
## Hazard rates over time
beta_e1 <- 2 # Death --> Increasing risk over time
beta_e2 <- 1 # Disease Progression --> Constant risk over time
## Correlation
rho <- 0.1 # Correlation between components
rho_type <- 'Spearman' # Type of correlation measure
copula <- 'Frank' # Copula used to get the joint distribution
## Additional parameter
case <- 3 # 1: No deaths; 2: Death is the secondary event;
# 3: Death is the primary event; 4: Both events are death by different causes
plot_tte(p0_e1, p0_e2, HR_e1, HR_e2, beta_e1, beta_e2, case,
copula = 'Frank', rho, rho_type='Spearman',
followup_time=1,
alpha=0.05, power=0.80 ,ss_formula='schoenfeld')
plot_tte(p0_e1, p0_e2, HR_e1, HR_e2, beta_e1, beta_e2, case,
copula = 'Frank', rho, rho_type='Spearman',
followup_time=1,
alpha=0.05, power=0.80 ,ss_formula='schoenfeld')
plot_tte(p0_e1, p0_e2, HR_e1, HR_e2, beta_e1, beta_e2, case,
copula = 'Frank', rho, rho_type='Spearman',
followup_time=1,
alpha=0.05, power=0.80 ,ss_formula='schoenfeld')
plot_surv <- surv_tte(p0_e1, p0_e2, HR_e1, HR_e2, beta_e1=beta_e1, beta_e2=beta_e2, case=case,
copula = copula, rho=rho, rho_type=rho_type,
followup_time=followup_time,
plot_res=FALSE,plot_save=TRUE)$gg_object
followup_time<- 1
plot_tte(p0_e1, p0_e2, HR_e1, HR_e2, beta_e1, beta_e2, case,
copula = 'Frank', rho, rho_type='Spearman',
followup_time,
alpha=0.05, power=0.80 ,ss_formula='schoenfeld')
plot_surv <- surv_tte(p0_e1, p0_e2, HR_e1, HR_e2, beta_e1=beta_e1, beta_e2=beta_e2, case=case,
copula = copula, rho=rho, rho_type=rho_type,
followup_time=followup_time,
plot_res=FALSE,plot_save=TRUE)$gg_object
plot_surv
surv_tte(p0_e1, p0_e2, HR_e1, HR_e2, beta_e1=beta_e1, beta_e2=beta_e2, case=case,
copula = copula, rho=rho, rho_type=rho_type,
followup_time=followup_time,
plot_res=TRUE,plot_save=TRUE)
plot_tte(p0_e1, p0_e2, HR_e1, HR_e2, beta_e1, beta_e2, case,
copula = 'Frank', rho, rho_type='Spearman',
followup_time,
alpha=0.05, power=0.80 ,ss_formula='schoenfeld')
#' Plot graphics related to the composite endpoint.
#'
#' @description Plot the survival function and the HR for composite endpoint over time and the ARE (Assymptotic Relative Efficiency) and sample size
#' size according to the correlation.The composite endpoint is assumed to be a time to event endpoint formed by a combination of two events (E1 and E2). We assume that the endpoint 1 is more relevant for the clinical question than endpoint 2.
#' #'
#'
#' @param p0_e1 numeric parameter between 0 and 1, expected proportion of observed events for the endpoint E1
#' @param p0_e2 numeric parameter between 0 and 1, expected proportion of observed events for the endpoint E2
#' @param HR_e1 numeric parameter between 0 and 1, expected cause specific hazard Ratio the endpoint E1
#' @param HR_e2 numeric parameter between 0 and 1, expected cause specific hazard Ratio the endpoint E2
#' @param beta_e1 numeric positive parameter, shape parameter (\eqn{\beta_1}) for a Weibull distribution for the endpoint E1 in the control group. See details for more info.
#' @param beta_e2 numeric positive parameter, shape parameter (\eqn{\beta_2}) for a Weibull distribution for the endpoint E2 in the control group. See details for more info.
#' @param case integer parameter in \{1,2,3,4\}: (1) none of the endpoints is death; (2) endpoint 2 is death; (3) endpoint 1 is death; (4) both endpoints are death by different causes.
#' @param copula character indicating the copula to be used: "Frank" (default), "Gumbel" or "Clayton". See details for more info.
#' @param rho numeric parameter between -1 and 1, Spearman's correlation coefficient o Kendall Tau between the marginal distribution of the times to the two events E1 and E2. See details for more info.
#' @param rho_type character indicating the type of correlation to be used: "Spearman" (default) or "Tau". See details for more info.
#' @param followup_time numeric parameter indicating the maximum follow up time (in any unit). Default is 1.
#' @param alpha numeric parameter. The probability of type I error. By default \eqn{\alpha=0.05}
#' @param power numeric parameter. The power to detect the treatment effect. By default \eqn{1-\beta=0.80}
#' @param ss_formula character indicating the formula to be used for the sample size calculation on the single components: 'schoenfeld' (default) or 'freedman'
#'
#' @import ggpubr
#' @export
#'
#' @return Four plots related to composite endpoint are returned:
#' \describe{
#' \item{S}{Survival curve for the composite endpoint over time}
#' \item{HR}{Hazard Ratio for the composite endpoint over time}
#' \item{ARE}{ARE according to correlation (\eqn{\rho})}
#' \item{SS}{Sample size for the composite endpoint according to correlation (\eqn{\rho})}
#' }
#'
#' @details Some parameters might be difficult to anticipate, especially the shape parameters of Weibull distributions and those referred to the relationship between the marginal distributions.
#' For the shape parameters (beta_e1, beta_e2) of the Weibull distribution, we recommend to use \eqn{\beta_j=0.5}, \eqn{\beta_j=1} or \eqn{\beta_j=2} if a decreasing, constant or increasing rates over time are expected, respectively.
#' For the correlation (rho) between both endpoints, generally a positive value is expected as it has no sense to design an study with two endpoints negatively correlated. We recommend to use \eqn{\rho=0.1}, \eqn{\rho=0.3} or \eqn{\rho=0.5} for weak, mild and moderate correlations, respectively.
#' For the type of correlation (rho_type), although two different type of correlations are implemented, we recommend the use of the Spearman's correlation.
#' In any case, if no information is available on these parameters, we recommend to use the default values provided by the function.
#'
#'
#'
plot_tte <- function(p0_e1, p0_e2, HR_e1, HR_e2, beta_e1=1, beta_e2=1, case,
copula = 'Frank', rho=0.3, rho_type='Spearman',
followup_time=1,
alpha=0.05, power=0.80 ,ss_formula='schoenfeld'){
requireNamespace("stats")
if(p0_e1 < 0 || p0_e1 > 1){
stop("The probability of observing the event E1 (p_e1) must be a number between 0 and 1")
}else if(p0_e2 < 0 || p0_e2 > 1){
stop("The probability of observing the event E2 (p_e2) must be a number between 0 and 1")
}else if(HR_e1 < 0 || HR_e1 > 1){
stop("The hazard ratio for the relevant endpoint E1 (HR_e1) must be a number between 0 and 1")
}else if(HR_e2 < 0 || HR_e2 > 1){
stop("The hazard ratio for the secondary endpoint E2 (HR_e2) must be a number between 0 and 1")
}else if(beta_e1 <= 0){
stop("The shape parameter for the marginal weibull distribution of the relevant endpoint E1 (beta_e1) must be a positive number")
}else if(beta_e2 <= 0){
stop("The shape parameter for the marginal weibull distribution of the secondary endpoint E2 (beta_e2) must be a positive number")
}else if(!case %in% 1:4){
stop("The case (case) must be a number in {1,2,3,4}. See ?ARE_tte")
}else if(!copula %in% c('Frank','Gumbel','Clayton')){
stop("The copula (copula) must be one of 'Frank','Gumbel' or 'Clayton'")
}else if(rho < -1 || rho > 1){
stop("The correlation (rho) must be a number between -1 and 1")
}else if(!rho_type %in% c('Spearman','Kendall')){
stop("The correlation type (rho_type) must be one of 'Spearman' or 'Kendall'")
}else if(case==4 && p0_e1 + p0_e2 > 1){
stop("The sum of the proportions of observed events in both endpoints in case 4 must be lower than 1")
}else if(!(is.numeric(followup_time) && followup_time>0)){
stop("The followup_time must be a positive numeric value")
}else if(alpha<=0 || alpha>=1){
stop("The probability of type I error (alpha) must be a numeric value between 0 and 1")
}else if(power<=0 || power>=1){
stop("The power must be a numeric value between 0 and 1")
}else if(!ss_formula %in% c('schoenfeld','freedman')){
stop("The selected formula (ss_formula) must be one of 'schoenfeld' (default) or 'freedman'")
}
invisible(capture.output(plot_surv <- surv_tte(p0_e1, p0_e2, HR_e1, HR_e2, beta_e1=beta_e1, beta_e2=beta_e2, case=case,
copula = copula, rho=rho, rho_type=rho_type,
followup_time=followup_time,
plot_res=FALSE,plot_save=TRUE)$gg_object))
invisible(capture.output(plot_effect <- effectsize_tte(p0_e1, p0_e2, HR_e1, HR_e2, beta_e1=beta_e1, beta_e2=beta_e2, case=case,
copula = copula, rho=rho, rho_type=rho_type,
followup_time=followup_time,
plot_res=FALSE,plot_save=TRUE)$gg_object))
invisible(capture.output(plot_ARE <- ARE_tte(p0_e1, p0_e2, HR_e1, HR_e2, beta_e1=beta_e1, beta_e2=beta_e2, case=case,
copula = copula, rho=rho, rho_type=rho_type,
plot_res=FALSE,plot_save=TRUE)$gg_object))
invisible(capture.output(plot_ss <- samplesize_tte(p0_e1, p0_e2, HR_e1, HR_e2, beta_e1=1, beta_e2=1, case,
copula = copula, rho=rho, rho_type=rho_type,
plot_res=FALSE,plot_save=TRUE,
alpha=0.05, power=0.80 ,ss_formula='schoenfeld')$gg_object))
print(ggarrange(plot_surv,
plot_effect,
plot_ARE,
plot_ss,ncol=2,nrow=2))
}
detach("package:CompAREdesign", unload = TRUE)
library(CompAREdesign)
detach("package:CompAREdesign", unload = TRUE)
p0_e1 <- 0.59 # Death
p0_e2 <- 0.74 # Disease Progression
## Effect size (Cause specific hazard ratios) for each endpoint
HR_e1 <- 0.91 # Death
HR_e2 <- 0.77 # Disease Progression
## Hazard rates over time
beta_e1 <- 2 # Death --> Increasing risk over time
beta_e2 <- 1 # Disease Progression --> Constant risk over time
## Correlation
rho <- 0.1 # Correlation between components
rho_type <- 'Spearman' # Type of correlation measure
copula <- 'Frank' # Copula used to get the joint distribution
## Additional parameter
case <- 3 # 1: No deaths; 2: Death is the secondary event;
# 3: Death is the primary event; 4: Both events are death by different causes
followup_time <- 1
plot_tte(p0_e1, p0_e2, HR_e1, HR_e2, beta_e1=1, beta_e2=1, case,
copula = 'Frank', rho=0.3, rho_type='Spearman',
followup_time,
alpha=0.05, power=0.80 ,ss_formula='schoenfeld')
plot_surv <- surv_tte(p0_e1, p0_e2, HR_e1, HR_e2, beta_e1=beta_e1, beta_e2=beta_e2, case=case,
copula = copula, rho=rho, rho_type=rho_type,
followup_time=followup_time,
plot_res=FALSE,plot_save=TRUE)$gg_object
plot_surv
surv_tte(p0_e1, p0_e2, HR_e1, HR_e2, beta_e1=beta_e1, beta_e2=beta_e2, case=case,
copula = copula, rho=rho, rho_type=rho_type,
followup_time=followup_time,
plot_res=TRUE,plot_save=TRUE)
plot_tte(p0_e1, p0_e2, HR_e1, HR_e2, beta_e1=1, beta_e2=1, case,
copula = 'Frank', rho=0.3, rho_type='Spearman',
followup_time,
alpha=0.05, power=0.80 ,ss_formula='schoenfeld'
plot_tte(p0_e1, p0_e2, HR_e1, HR_e2, beta_e1=1, beta_e2=1, case,
copula = 'Frank', rho=0.3, rho_type='Spearman',
followup_time,
alpha=0.05, power=0.80 ,ss_formula='schoenfeld')
followup_time <- 3
plot_tte(p0_e1, p0_e2, HR_e1, HR_e2, beta_e1=1, beta_e2=1, case,
copula = 'Frank', rho=0.3, rho_type='Spearman',
followup_time,
alpha=0.05, power=0.80 ,ss_formula='schoenfeld')
plot_tte(p0_e1, p0_e2, HR_e1, HR_e2, beta_e1=1, beta_e2=1, case,
copula = 'Frank', rho=0.3, rho_type='Spearman',
followup_time,
alpha=0.05, power=0.80 ,ss_formula='schoenfeld')
followup_time <- 1
plot_tte(p0_e1, p0_e2, HR_e1, HR_e2, beta_e1=1, beta_e2=1, case,
copula = 'Frank', rho=0.3, rho_type='Spearman',
followup_time,
alpha=0.05, power=0.80 ,ss_formula='schoenfeld')
followup_time <- 1
plot_tte(p0_e1, p0_e2, HR_e1, HR_e2, beta_e1, beta_e2, case,
copula = 'Frank', rho=0.3, rho_type='Spearman',
followup_time,
alpha=0.05, power=0.80 ,ss_formula='schoenfeld')
## Probabilities of observing the event in control arm during follow-up
p0_e1 <- 0.59 # Death
p0_e2 <- 0.74 # Disease Progression
## Effect size (Cause specific hazard ratios) for each endpoint
HR_e1 <- 0.91 # Death
HR_e2 <- 0.77 # Disease Progression
## Hazard rates over time
beta_e1 <- 2 # Death --> Increasing risk over time
beta_e2 <- 1 # Disease Progression --> Constant risk over time
## Correlation
rho <- 0.1 # Correlation between components
rho_type <- 'Spearman' # Type of correlation measure
copula <- 'Frank' # Copula used to get the joint distribution
## Additional parameter
case <- 3 # 1: No
followup_time <- 1
plot_tte(p0_e1, p0_e2, HR_e1, HR_e2, beta_e1, beta_e2, case,
copula = 'Frank', rho=0.3, rho_type='Spearman',
followup_time,
alpha=0.05, power=0.80 ,ss_formula='schoenfeld')
followup_time <- 3
plot_tte(p0_e1, p0_e2, HR_e1, HR_e2, beta_e1, beta_e2, case,
copula = 'Frank', rho=0.3, rho_type='Spearman',
followup_time,
alpha=0.05, power=0.80 ,ss_formula='schoenfeld')
followup_time <- 30
plot_tte(p0_e1, p0_e2, HR_e1, HR_e2, beta_e1, beta_e2, case,
copula = 'Frank', rho=0.3, rho_type='Spearman',
followup_time,
alpha=0.05, power=0.80 ,ss_formula='schoenfeld')
followup_time <- 1
plot_tte(p0_e1, p0_e2, HR_e1, HR_e2, beta_e1, beta_e2, case,
copula = 'Frank', rho=0.3, rho_type='Spearman',
followup_time,
alpha=0.05, power=0.80 ,ss_formula='schoenfeld')
plot_surv <- surv_tte(p0_e1, p0_e2, HR_e1, HR_e2, beta_e1=beta_e1, beta_e2=beta_e2, case=case,
copula = copula, rho=rho, rho_type=rho_type,
followup_time=followup_time,
plot_res=FALSE,plot_save=TRUE)$gg_object
plot_surv
plot_surv + theme_dark()
plot_surv + theme_bwk()
plot_surv + theme_bw()
a <- plot_surv + theme_bw()
plot_surv <- surv_tte(p0_e1, p0_e2, HR_e1, HR_e2, beta_e1=beta_e1, beta_e2=beta_e2, case=case,
copula = copula, rho=rho, rho_type=rho_type,
followup_time=followup_time,
plot_res=FALSE,plot_save=TRUE)$gg_object
plot_surv
theme_bw
plot_surv + theme_bw()
library(ggplot2)
plot_surv + theme_bw()
plot_tte + theme_bw()
plot_tte
plots <- plot_tte(p0_e1, p0_e2, HR_e1, HR_e2, beta_e1, beta_e2, case,
copula = 'Frank', rho=0.3, rho_type='Spearman',
followup_time,
alpha=0.05, power=0.80 ,ss_formula='schoenfeld')
plots
plots + theme_bw()
plots <- plot_tte(p0_e1, p0_e2, HR_e1, HR_e2, beta_e1, beta_e2, case,
copula = 'Frank', rho=0.3, rho_type='Spearman',
followup_time,
alpha=0.05, power=0.80 ,ss_formula='schoenfeld', tema = theme_bw())
plot_surv
plots
plots <- plot_tte(p0_e1, p0_e2, HR_e1, HR_e2, beta_e1, beta_e2, case,
copula = 'Frank', rho=0.3, rho_type='Spearman',
followup_time,
alpha=0.05, power=0.80 ,ss_formula='schoenfeld')
plots <- plot_tte(p0_e1, p0_e2, HR_e1, HR_e2, beta_e1, beta_e2, case,
copula = 'Frank', rho=0.3, rho_type='Spearman',
followup_time,
alpha=0.05, power=0.80 ,ss_formula='schoenfeld', tema = theme_void())
plots <- plot_tte(p0_e1, p0_e2, HR_e1, HR_e2, beta_e1, beta_e2, case,
copula = 'Frank', rho=0.3, rho_type='Spearman',
followup_time,
alpha=0.05, power=0.80 ,ss_formula='schoenfeld', tema = theme_tufte())
plots <- plot_tte(p0_e1, p0_e2, HR_e1, HR_e2, beta_e1, beta_e2, case,
copula = 'Frank', rho=0.3, rho_type='Spearman',
followup_time,
alpha=0.05, power=0.80 ,ss_formula='schoenfeld', tema = theme_classic())
plots <- plot_tte(p0_e1, p0_e2, HR_e1, HR_e2, beta_e1, beta_e2, case,
copula = 'Frank', rho=0.3, rho_type='Spearman',
followup_time,
alpha=0.05, power=0.80 ,ss_formula='schoenfeld')
plots <- plot_tte(p0_e1, p0_e2, HR_e1, HR_e2, beta_e1, beta_e2, case,
copula = 'Frank', rho=0.3, rho_type='Spearman',
followup_time,
alpha=0.05, power=0.80 ,ss_formula='schoenfeld', tema = theme_bw())
plots <- plot_tte(p0_e1, p0_e2, HR_e1, HR_e2, beta_e1, beta_e2, case,
copula = 'Frank', rho=0.3, rho_type='Spearman',
followup_time,
alpha=0.05, power=0.80 ,ss_formula='schoenfeld')
plots
plot_tte(p0_e1, p0_e2, HR_e1, HR_e2, beta_e1, beta_e2, case,
copula = 'Frank', rho=0.3, rho_type='Spearman',
followup_time,
alpha=0.05, power=0.80 ,ss_formula='schoenfeld')
plot_surv <- surv_tte(p0_e1, p0_e2, HR_e1, HR_e2, beta_e1=beta_e1, beta_e2=beta_e2, case=case,
copula = copula, rho=rho, rho_type=rho_type,
followup_time=followup_time,
plot_res=FALSE,plot_save=TRUE)$gg_object
plot_surv
surv_tte(p0_e1, p0_e2, HR_e1, HR_e2, beta_e1=beta_e1, beta_e2=beta_e2, case=case,
copula = copula, rho=rho, rho_type=rho_type,
followup_time=followup_time,
plot_res=FALSE,plot_save=TRUE)$gg_object
plot_surv
plot_tte(p0_e1, p0_e2, HR_e1, HR_e2, beta_e1, beta_e2, case,
copula = 'Frank', rho=0.3, rho_type='Spearman',
followup_time,
alpha=0.05, power=0.80 ,ss_formula='schoenfeld')
plot_tte(p0_e1, p0_e2, HR_e1, HR_e2, beta_e1, beta_e2, case,
copula = 'Frank', rho=0.3, rho_type='Spearman',
followup_time,
alpha=0.05, power=0.80 ,ss_formula='schoenfeld')
surv_tte(p0_e1, p0_e2, HR_e1, HR_e2, beta_e1=beta_e1, beta_e2=beta_e2, case=case,
copula = copula, rho=rho, rho_type=rho_type,
followup_time=followup_time,
plot_res=FALSE,plot_save=TRUE)$gg_object
plot_surv <- surv_tte(p0_e1, p0_e2, HR_e1, HR_e2, beta_e1=beta_e1, beta_e2=beta_e2, case=case,
copula = copula, rho=rho, rho_type=rho_type,
followup_time=followup_time,
plot_res=FALSE,plot_save=TRUE)$gg_object
plot_surv
plot_surv <- surv_tte(p0_e1, p0_e2, HR_e1, HR_e2, beta_e1=beta_e1, beta_e2=beta_e2, case=case,
copula = copula, rho=rho, rho_type=rho_type,
followup_time=followup_time,
plot_res=TRUE,plot_save=TRUE)$gg_object
plot_tte(p0_e1, p0_e2, HR_e1, HR_e2, beta_e1, beta_e2, case,
copula = 'Frank', rho=0.3, rho_type='Spearman',
followup_time,
alpha=0.05, power=0.80 ,ss_formula='schoenfeld')
plot_tte(p0_e1, p0_e2, HR_e1, HR_e2, beta_e1, beta_e2, case,
copula = 'Frank', rho=0.3, rho_type='Spearman',
followup_time,
alpha=0.05, power=0.80 ,ss_formula='schoenfeld')
plot_tte(p0_e1, p0_e2, HR_e1, HR_e2, beta_e1, beta_e2, case,
copula = 'Frank', rho=0.3, rho_type='Spearman',
followup_time,
alpha=0.05, power=0.80 ,ss_formula='schoenfeld', theme_bw())
plot_tte(p0_e1, p0_e2, HR_e1, HR_e2, beta_e1, beta_e2, case,
copula = 'Frank', rho=0.3, rho_type='Spearman',
followup_time,
alpha=0.05, power=0.80 ,ss_formula='schoenfeld', title("prova"))
plot_tte(p0_e1, p0_e2, HR_e1, HR_e2, beta_e1, beta_e2, case,
copula = 'Frank', rho=0.3, rho_type='Spearman',
followup_time,
alpha=0.05, power=0.80 ,ss_formula='schoenfeld', title ="prova")
rlang::last_trace()
plot_tte(p0_e1, p0_e2, HR_e1, HR_e2, beta_e1, beta_e2, case,
copula = 'Frank', rho=0.3, rho_type='Spearman',
followup_time,
alpha=0.05, power=0.80 ,ss_formula='schoenfeld', labs(title ="prova"))
plot_tte(p0_e1, p0_e2, HR_e1, HR_e2, beta_e1, beta_e2, case,
copula = 'Frank', rho=0.3, rho_type='Spearman',
followup_time,
alpha=0.05, power=0.80 ,ss_formula='schoenfeld', theme_bw())
plot_tte(p0_e1, p0_e2, HR_e1, HR_e2, beta_e1, beta_e2, case,
copula = 'Frank', rho=0.3, rho_type='Spearman',
followup_time,
alpha=0.05, power=0.80 ,ss_formula='schoenfeld')
plot_surv <- surv_tte(p0_e1, p0_e2, HR_e1, HR_e2, beta_e1=beta_e1, beta_e2=beta_e2, case=case,
copula = copula, rho=rho, rho_type=rho_type,
followup_time=followup_time,
plot_res=FALSE,plot_save=TRUE)$gg_object
plot_surv
rlang::last_trace()
rlang::last_trace(drop = FALSE)
plot_tte(p0_e1, p0_e2, HR_e1, HR_e2, beta_e1, beta_e2, case,
copula = 'Frank', rho=0.3, rho_type='Spearman',
followup_time,
alpha=0.05, power=0.80 ,ss_formula='schoenfeld')
plot_tte(p0_e1, p0_e2, HR_e1, HR_e2, beta_e1, beta_e2, case,
copula = 'Frank', rho=0.3, rho_type='Spearman',
followup_time,
alpha=0.05, power=0.80 ,ss_formula='schoenfeld', theme_bw())
plot_tte(p0_e1, p0_e2, HR_e1, HR_e2, beta_e1, beta_e2, case,
copula = 'Frank', rho=0.3, rho_type='Spearman',
followup_time,
alpha=0.05, power=0.80 ,ss_formula='schoenfeld', theme_bw(), labs(title = "prova"))
plot_tte(p0_e1, p0_e2, HR_e1, HR_e2, beta_e1, beta_e2, case,
copula = 'Frank', rho=0.3, rho_type='Spearman',
followup_time,
alpha=0.05, power=0.80 ,ss_formula='schoenfeld', labs(title = "prova"))
plot_tte(p0_e1, p0_e2, HR_e1, HR_e2, beta_e1, beta_e2, case,
copula = 'Frank', rho=0.3, rho_type='Spearman',
followup_time,
alpha=0.05, power=0.80 ,ss_formula='schoenfeld', labs(title = "prova"), theme_bw())
plot_tte(p0_e1, p0_e2, HR_e1, HR_e2, beta_e1, beta_e2, case,
copula = 'Frank', rho=0.3, rho_type='Spearman',
followup_time,
alpha=0.05, power=0.80 ,ss_formula='schoenfeld', theme_bw())
plot_tte(p0_e1, p0_e2, HR_e1, HR_e2, beta_e1, beta_e2, case,
copula = 'Frank', rho=0.3, rho_type='Spearman',
followup_time,
alpha=0.05, power=0.80 ,ss_formula='schoenfeld', theme_bw())
plot_tte(p0_e1, p0_e2, HR_e1, HR_e2, beta_e1, beta_e2, case,
copula = 'Frank', rho=0.3, rho_type='Spearman',
followup_time,
alpha=0.05, power=0.80 ,ss_formula='schoenfeld')
## Probabilities of observing the event in control arm during follow-up
p0_e1 <- 0.59 # Death
p0_e2 <- 0.74 # Disease Progression
## Effect size (Cause specific hazard ratios) for each endpoint
HR_e1 <- 0.91 # Death
HR_e2 <- 0.77 # Disease Progression
## Hazard rates over time
beta_e1 <- 2 # Death --> Increasing risk over time
beta_e2 <- 1 # Disease Progression --> Constant risk over time
## Correlation
rho <- 0.1 # Correlation between components
rho_type <- 'Spearman' # Type of correlation measure
copula <- 'Frank' # Copula used to get the joint distribution
## Additional parameter
case <- 3 # 1: No deaths; 2: Death is the secondary event;
# 3: Death is the primary event; 4: Both events are death by different causes
followup_time <- 1
plot_tte(p0_e1, p0_e2, HR_e1, HR_e2, beta_e1, beta_e2, case,
copula = 'Frank', rho=0.3, rho_type='Spearman',
followup_time,
alpha=0.05, power=0.80 , ss_formula='schoenfeld',
theme_bw(),
labs(title = "Composite Endpoint Analysis",
subtitle = "Sample Size and Efficiency"))
library(ggplot2)
plot_tte(p0_e1, p0_e2, HR_e1, HR_e2, beta_e1, beta_e2, case,
copula = 'Frank', rho=0.3, rho_type='Spearman',
followup_time,
alpha=0.05, power=0.80 , ss_formula='schoenfeld',
theme_bw(),
labs(title = "Composite Endpoint Analysis",
subtitle = "Sample Size and Efficiency"))
## Probabilities of observing the event in control arm during follow-up
p0_e1 <- 0.59 # Death
p0_e2 <- 0.74 # Disease Progression
## Effect size (Cause specific hazard ratios) for each endpoint
HR_e1 <- 0.91 # Death
HR_e2 <- 0.77 # Disease Progression
## Hazard rates over time
beta_e1 <- 2 # Death --> Increasing risk over time
beta_e2 <- 1 # Disease Progression --> Constant risk over time
## Correlation
rho <- 0.1 # Correlation between components
rho_type <- 'Spearman' # Type of correlation measure
copula <- 'Frank' # Copula used to get the joint distribution
## Additional parameter
case <- 3 # 1: No deaths; 2: Death is the secondary event;
# 3: Death is the primary event; 4: Both events are death by different causes
eff_e1 <- -0.0196
eff_e2 <- -0.0098
effm_e1 <- "diff"
effm_e2 <- "diff"
samplesize <- 100
simula_cbe(p0_e1, p0_e2, eff_e1, effm_e1, eff_e2, effm_e2, rho, samplesize)
test <- simula_cbe(p0_e1, p0_e2, eff_e1, effm_e1, eff_e2, effm_e2, rho, samplesize)
test <- simula_cbe(p0_e1, p0_e2, eff_e1, effm_e1, eff_e2, effm_e2, rho, samplesize)
View(test)