diff --git a/R/milestone.R b/R/milestone.R index 3240bec4..21f145d1 100644 --- a/R/milestone.R +++ b/R/milestone.R @@ -53,7 +53,6 @@ #' cut_data |> #' milestone(10, test_type = "naive") milestone <- function(data, ms_time, test_type = c("log-log", "naive")) { - test_type <- match.arg(test_type) # Fit into KM curves @@ -83,7 +82,7 @@ milestone <- function(data, ms_time, test_type = c("log-log", "naive")) { if (na_ctrl + na_exp == 2) { z <- -Inf } else { - if (test_type == "naive"){ + if (test_type == "naive") { z_numerator <- surv_diff z_denominator <- surv_exp * sqrt(sigma2_exp) + surv_ctrl * sqrt(sigma2_ctrl) } else if (test_type == "log-log") { diff --git a/R/sim_gs_n.R b/R/sim_gs_n.R index 571ee366..68c51db5 100644 --- a/R/sim_gs_n.R +++ b/R/sim_gs_n.R @@ -203,13 +203,19 @@ #' # Example 8: At IA1, we conduct 3 tests, LR, WLR with fh(0, 0.5), and RMST test. #' # At IA2, we conduct 2 tests, LR and WLR with early zero (6). #' # At FA, we conduct 2 tests, LR and milestone test. -#' ia1_test <- list(test1 = create_test(wlr, weight = fh(rho = 0, gamma = 0)), -#' test2 = create_test(wlr, weight = fh(rho = 0, gamma = 0.5)), -#' test3 = create_test(rmst, tau = 20)) -#' ia2_test <- list(test1 = create_test(wlr, weight = fh(rho = 0, gamma = 0)), -#' test2 = create_test(wlr, weight = early_zero(6))) -#' fa_test <- list(test1 = create_test(wlr, weight = fh(rho = 0, gamma = 0)), -#' test3 = create_test(milestone, ms_time = 20)) +#' ia1_test <- list( +#' test1 = create_test(wlr, weight = fh(rho = 0, gamma = 0)), +#' test2 = create_test(wlr, weight = fh(rho = 0, gamma = 0.5)), +#' test3 = create_test(rmst, tau = 20) +#' ) +#' ia2_test <- list( +#' test1 = create_test(wlr, weight = fh(rho = 0, gamma = 0)), +#' test2 = create_test(wlr, weight = early_zero(6)) +#' ) +#' fa_test <- list( +#' test1 = create_test(wlr, weight = fh(rho = 0, gamma = 0)), +#' test3 = create_test(milestone, ms_time = 20) +#' ) #' \dontrun{ #' sim_gs_n( #' n_sim = 3, diff --git a/tests/testthat/test-unvalidated-sim_gs_n.R b/tests/testthat/test-unvalidated-sim_gs_n.R index 7cc192c9..fdf5522c 100644 --- a/tests/testthat/test-unvalidated-sim_gs_n.R +++ b/tests/testthat/test-unvalidated-sim_gs_n.R @@ -238,13 +238,13 @@ test_that("WLR with fh(0, 0.5) test at IA1, WLR with mb(6, Inf) at IA2, and mile fa_test <- create_test(milestone, ms_time = 10, test_type = "naive") observed <- sim_gs_n( - n_sim = 3, - sample_size = 400, - enroll_rate = test_enroll_rate(), - fail_rate = test_fail_rate(), - test = list(ia1 = ia1_test, ia2 = ia2_test, fa = fa_test), - cut = test_cutting(), - seed = 2024 + n_sim = 3, + sample_size = 400, + enroll_rate = test_enroll_rate(), + fail_rate = test_fail_rate(), + test = list(ia1 = ia1_test, ia2 = ia2_test, fa = fa_test), + cut = test_cutting(), + seed = 2024 ) expected <- data.frame( sim_id = rep(1:3, each = 3L),