Skip to contents

This function uses Monte Carlo simulation to calculate the variance-covariance matrix of [E1-C1, E1, E2-C2, E2]. The calculation formula refers to Lu (2021) sequential trials. The input rmst_int should be the interim RMST data of two groups (generated by RMST_sim_cal). rmst_fin is the final RMST data of two groups (generated by RMST_sim_cal).

Usage

mu_cov_mc(rmst_int, rmst_fin, sim_size)

Arguments

rmst_int

A matrix of interim RMST data generated by RMST_sim_cal function.

rmst_fin

A matrix of final stage RMST data generated by RMST_sim_cal function.

sim_size

n integer representing the number of Monte Carlo simulation iterations.

Value

A list with the following components:

mu

A numeric vector of the means [mean(E1-C1), mean(E1), mean(E2-C2), mean(E2)].

sigma

A 4x4 variance-covariance matrix of [E1-C1, E1, E2-C2, E2].

Examples

# Example usage of mu_cov_mc
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
tau_f <- 2.5

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)
rmst_h0_int <- RMST_sim_cal(n = n, data_E = data_E_H0[ , c(2,3,1)], 
                           data_C = data_C[ , c(2,3,1)],
                           tau = interim, sim_size = sim_size)
#> Error in makeCluster(n_cores): could not find function "makeCluster"
rmst_h0_fin <- RMST_sim_cal(n = n, data_E = data_E_H0[ , c(4,5,1)], 
                           data_C = data_C[ , c(4,5,1)],
                           tau = tau_f, sim_size = sim_size)
#> Error in makeCluster(n_cores): could not find function "makeCluster"
mu_cov_h0 <- mu_cov_mc(rmst_int = rmst_h0_int, rmst_fin = rmst_h0_fin, sim_size = sim_size)
#> Error: object 'rmst_h0_int' not found

# print(mu_cov_h0$mu)
# print(mu_cov_h0$sigma)