Adaptive grid search for critical value using RMST (Simple or Sculpted (parallel))
adp_grid_src.RdThis is the function for adaptive grid search of RMST two-stage design with one searching parameters gamma.
The grid search make use of the conditional distribution (Normal) of E | D, which is illustrated in paper.
When power is not given, the function finds the critical values that control the overall type I error < alpha
while maximizing the empirical power. When power is given, it searches for valid critical values such that the empirical
power is greater than the specified power. If power is given, int_n and fin_n are required
Usage
adp_grid_src(
rmst_data,
mu_cov_h0,
mu_cov_h1,
int_n,
fin_n,
sim_size,
method,
alpha,
power = NULL
)Arguments
- rmst_data
Combined RMST data generated by the
RMST_sim_calfunction.- mu_cov_h0
Variance-covariance matrix of (E1-C1, E1, E2-C2, E2) under the null hypothesis (H0), obtained from the
mu_cov_mcfunction.- mu_cov_h1
Variance-covariance matrix of (E1-C1, E1, E2-C2, E2) under the alternative hypothesis (H1), obtained from the
mu_cov_mcfunction.- int_n
Interim sample size (n).
- fin_n
Total sample size (N).
- sim_size
Number of simulations to perform in the grid search.
- method
Method used for the RMST design. "Simple" indicates a Simple RMST with the rejection region (D1 > m1 & D2 > m2), where D = E - C is the RMST difference between groups. "Complex" indicates a Sculpted RMST with the rejection region (D1 > m1 & E1 > q1 & D2 > m2 & E2 > q2), where E is the RMST in the experimental group.
- alpha
Stated type I error level.
- power
Desired power of the test (optional).
Value
A data frame with the following columns:
- m1
Critical value for RMST difference at the first stage
- m2
Critical value for RMST difference at the second stage
- q1
Critical value for Experiment group RMST at the first stage
- q2
Critical value for Experiment group RMST at the second stage
- PET0
Probability of early termination under H0.
- PET1
Probability of early termination under H1.
- alpha
Empirical overall type I error rate.
- power
Empirical power of the test.
- PET
Probability of early termination
(PET0+PET1)/2.- EN0
Expected sample size under H0.
- EN1
Expected sample size under H1.
- EN
Average expected sample size.
If no valid critical values are found, the function returns a data frame with m1 = 0, m2 = 0, q1 = 0, q2 = 0, PET0 = 0, PET1 = 0, alpha = 0, power = 0, PET = 0, EN0 = NA, EN1 = NA, EN = NA.
Examples
# Example usage of adp_grid_src function
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
# Generate data for control arm (C) and experimental arm (E) under H0 and H1
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)
data_E_H1 <- expo_gen_2stages(N = n * sim_size, acc_time = acc_time,
lambda = lambda_H1, dist = 'exp',
cen_time = cen_time, arm = 1, interim = interim)
# Calculate RMST data for interim and final stages under H0 and H1
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"
rmst_h1_int <- RMST_sim_cal(n = n, data_E = data_E_H1[ , 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_h1_fin <- RMST_sim_cal(n = n, data_E = data_E_H1[ , 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"
# Combine RMST data
rmst_data <- rbind(rmst_h0_int, rmst_h1_int, rmst_h0_fin, rmst_h1_fin)
#> Error: object 'rmst_h0_int' not found
# Calculate variance-covariance matrices under H0 and H1
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
mu_cov_h1 <- mu_cov_mc(rmst_int = rmst_h1_int, rmst_fin = rmst_h1_fin, sim_size = sim_size)
#> Error: object 'rmst_h1_int' not found
# Perform adaptive grid search for the best RMST design
best_RMST <- adp_grid_src(rmst_data = rmst_data, mu_cov_h0 = mu_cov_h0,
mu_cov_h1 = mu_cov_h1, int_n = interim * r, fin_n = 2 * n,
alpha = 0.05, sim_size = sim_size, method = 'Complex')
#> Error in makeCluster(n_cores): could not find function "makeCluster"