# The following code takes more than 5 seconds to run.
# \donttest{
# define design parameters
t_enrl <- 12; t_fup <- 18; lmd0 <- log(2)/12
# define hazard ratio function
f_hr_delay <- function(x){(x<=6)+(x>6)*0.75}
# define control hazard
f_haz0 <- function(x){lmd0*x^0}
# perform sample size calculation using logrank test
# generate weight for test
wlr <- gen.wgt(method="LR")
snph1 <- pwr2n.NPH(entry = t_enrl, fup = t_fup, Wlist = wlr,
k = 100, ratio = 2, CtrlHaz = f_haz0, hazR = f_hr_delay)
# suppose the follow-up duration that are taken into consideration ranges
# from 12 to 24. The planned number of patients to recruit 2200.
# draw the graph
efun <- evalfup(snph1,lower.time = 12, upper.time = 24, size = 2200,
title = NULL)
# }
Run the code above in your browser using DataLab