Skip to content

Commit

Permalink
Add snapshot test for sim_gs_n() with milestone() test
Browse files Browse the repository at this point in the history
  • Loading branch information
jdblischak committed Mar 7, 2024
1 parent 5a8bf36 commit 55347a2
Showing 1 changed file with 55 additions and 2 deletions.
57 changes: 55 additions & 2 deletions tests/testthat/test-unvalidated-sim_gs_n.R
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 55347a2

Please sign in to comment.