From 55347a2bd47280ac1d518286d92c861b75680c1f Mon Sep 17 00:00:00 2001 From: John Blischak Date: Wed, 6 Mar 2024 16:00:15 -0500 Subject: [PATCH] Add snapshot test for sim_gs_n() with milestone() test --- tests/testthat/test-unvalidated-sim_gs_n.R | 57 +++++++++++++++++++++- 1 file changed, 55 insertions(+), 2 deletions(-) diff --git a/tests/testthat/test-unvalidated-sim_gs_n.R b/tests/testthat/test-unvalidated-sim_gs_n.R index cf578031..5a5b119d 100644 --- a/tests/testthat/test-unvalidated-sim_gs_n.R +++ b/tests/testthat/test-unvalidated-sim_gs_n.R @@ -59,7 +59,7 @@ test_that("Test 2: weighted logrank test by FH(0, 0.5)", { expect_equal(observed, expected) }) -test_that("Test 3: weighted logrank test by MB(6)", { +test_that("Test 3: weighted logrank test by MB(3)", { observed <- sim_gs_n( n_sim = 3, sample_size = 400, @@ -152,7 +152,60 @@ test_that("Test 5: RMST", { expect_equal(observed, expected) }) -test_that("Test 6: maxcombo (FH(0,0) + FH(0, 0.5))", { +test_that("Test 6: Milestone", { + observed <- sim_gs_n( + n_sim = 3, + sample_size = 400, + enroll_rate = test_enroll_rate(), + fail_rate = test_fail_rate(), + test = milestone, + cutting = test_cutting(), + seed = 2024, + ms_time = 10 + ) + expected <- data.frame( + method = rep("milestone", 9L), + z = c( + 9.252619142383594, 12.078380683791904, 12.078380683791904, 5.565741269919053, + 5.457930240636103, 5.457930240636103, 9.051772787302813, 9.054982526543846, + 9.054982526543846 + ), + ms_time = rep(10, 9L), + surv_ctrl = c( + 0.40800409626773176, 0.40972689075630214, 0.40972689075630214, + 0.4718268722892688, 0.46670065754089335, 0.46670065754089335, + 0.46149611243704863, 0.46199999999999974, 0.46199999999999974 + ), + surv_exp = c( + 0.568975019886668, 0.5849999999999997, 0.5849999999999997, 0.5922853919588814, + 0.5840900715499292, 0.5840900715499292, 0.6150543366195163, + 0.6139773404060171, 0.6139773404060171 + ), + surv_diff = c( + 0.16097092361893622, 0.1752731092436976, 0.1752731092436976, + 0.12045851966961263, 0.11738941400903585, 0.11738941400903585, + 0.15355822418246762, 0.1519773404060174, 0.1519773404060174 + ), + std_err_ctrl = c( + 0.03693587681297664, 0.034952703615152854, 0.034952703615152854, + 0.03614098127448581, 0.035432630739150366, 0.035432630739150366, + 0.035815727559287504, 0.03540131462139614, 0.03540131462139614 + ), + std_err_exp = c( + 0.03662189834863626, 0.03484070894801079, 0.03484070894801079, + 0.035312669921649095, 0.034912158581439694, 0.034912158581439694, + 0.03505127094114008, 0.034738243333119145, 0.034738243333119145 + ), + analysis = rep(1:3, 3), + cut_date = c(24, 32, 45, 24, 32, 46.219327415802894, 24, 32, 50.86585486314699), + sim_id = rep(1:3, each = 3L), + n = rep(400L, 9L), + event = c(229, 295, 355, 241, 290, 350, 226, 282, 350) + ) + expect_equal(observed, expected) +}) + +test_that("Test 7: MaxCombo (WLR-FH(0,0) + WLR-FH(0, 0.5))", { observed <- sim_gs_n( n_sim = 3, sample_size = 400,