#------------------------------------------------------------
## Delayed treatment effects using maxcombo test
## generate a list of weight functions for maxcombot test
wmax <- gen.wgt(method = "Maxcombo" )
t_enrl <- 12; t_fup <- 18; lmd0 <- log(2)/12
## delayed treatment effects
f_hr_delay <- function(x){(x<=6)+(x>6)*0.75}
f_haz0 <- function(x){lmd0*x^0}
## The following code takes more than 5 seconds to run
# \donttest{
snph1 <- pwr2n.NPH(entry = t_enrl, fup = t_fup, Wlist = wmax,
k = 100, ratio = 2, CtrlHaz = f_haz0, hazR = f_hr_delay)
# }
#-------------------------------------------------------------
# same setting using projection test
snph2 <- pwr2n.NPH(method = "Projection", entry = t_enrl,
fup = t_fup, Wlist = wmax, k = 10, ratio = 2, CtrlHaz = f_haz0,
hazR = f_hr_delay)
#-------------------------------------------------------------
#proportional hazards with weibull survival for control group
#logrank test
wlr <- gen.wgt(method = "LR" )
b0 <- 3
th0 <- 10/(-log(0.2))^(1/b0)
#Weibull hazard function
f_hz_weibull <- function(x){b0/th0^b0*x^(b0-1)}
#hazard ratio function
f_hr <- function(x){0.5*x^0}
# define entry and follow-up time
t_enrl <- 5; t_fup <- 5
exph1 <- pwr2n.NPH(entry = t_enrl, fup = t_fup, k = 100,
Wlist = wlr, CtrlHaz = f_hz_weibull, hazR = f_hr, summary = FALSE)
summary(exph1)
Run the code above in your browser using DataLab