Log-rank test simulation. P-value and z-statistics (parallel)
log_rank_sim.RdFor log-rank test simulation. Single-stage p-value or two-stage statistics. Return the simulated type I error, empirical mean and variance of Z-statistics of log-rank test
Arguments
- data_C
Survival data of control group generated by expo_gen_2stages
- data_E
Survival data of experiment group generated by expo_gen_2stages
- sim_size
simulation times
- n
Sample size in each arm
- alpha
Stated type I error level
- sided
"two_sided" for two-sided test, "greater" for one-sided superiority test
Value
A list with the following components:
- rejection
The proportion of simulations where the log-rank test statistic is less than or equal to alpha.
- z_stats
A numeric vector of the z statistics W/sigma for each simulation.
- var_w
The variance of statistics $W$ for correlation calculation.
Examples
sim_size <- 5000
N <- 100
r <- 60
acc_time <- N / r
cen_time <- 1
lambda_H1 <- 0.9
HR <- 1.7
lambda_H0 <- 0.9 * 1.7
change_time <- 1
interim <- 0.6 * acc_time
n <- ceiling(N / 2)
alpha <- 0.05
data_C <- expo_gen_2stages(N = n * sim_size, acc_time = acc_time,
lambda = lambda_H0, dist = 'exp',
cen_time = cen_time,arm = 0, interim = interim)
data_E_H0 <- expo_gen_2stages(N = n * sim_size, acc_time = acc_time,
lambda = lambda_H0, dist = 'exp',
cen_time = cen_time,arm = 1, interim = interim)
lr_h0_int <- log_rank_sim(data_C = data_C[ , c(2,3,1)], data_E = data_E_H0[ , c(2,3,1)],
sim_size = sim_size, n = n, alpha = alpha, sided = 'greater')
#> Error in makeCluster(n_cores): could not find function "makeCluster"
# print(lr_h0_int$rejection)
# print(lr_h0_int$z_stats)
# print(lr_h0_int$var_w)