Skip to content

Commit

Permalink
Update sim_gs_n() tests for overhauled milestone()
Browse files Browse the repository at this point in the history
milestone() was recently overhauled to

1. Use the log-log method to calculate the `estimate`. Setting
   `test_type = "naive"` restored the previous value
1. Return a single value for `se` instead of two
1. Return the unsquared Z statistic for `z`

Merck#237
  • Loading branch information
jdblischak committed May 7, 2024
1 parent a3172c5 commit a6dc71a
Showing 1 changed file with 28 additions and 39 deletions.
67 changes: 28 additions & 39 deletions tests/testthat/test-unvalidated-sim_gs_n.R
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,8 @@ test_that("Milestone", {
test = milestone,
cut = test_cutting(),
seed = 2024,
ms_time = 10
ms_time = 10,
test_type = "naive"
)
expected <- data.frame(
sim_id = rep(1:3, each = 3L),
Expand All @@ -217,21 +218,15 @@ test_that("Milestone", {
0.12045851966961263, 0.11738941400903585, 0.11738941400903585,
0.15355822418246762, 0.1519773404060174, 0.1519773404060174
),
se = I(list(
c(0.03693587681297664, 0.03662189834863626),
c(0.034952703615152854, 0.03484070894801079),
c(0.034952703615152854, 0.03484070894801079),
c(0.03614098127448581, 0.035312669921649095),
c(0.035432630739150366, 0.034912158581439694),
c(0.035432630739150366, 0.034912158581439694),
c(0.035815727559287504, 0.03505127094114008),
c(0.03540131462139614, 0.034738243333119145),
c(0.03540131462139614, 0.034738243333119145)
)),
se = c(
0.0735577751616129, 0.06979341256316365, 0.06979341256316365,
0.0714536511961349, 0.07034478932059006, 0.07034478932059006,
0.07086699850042757, 0.07013955795451529, 0.07013955795451529
),
z = c(
9.252619142383594, 12.078380683791904, 12.078380683791904, 5.565741269919053,
5.457930240636103, 5.457930240636103, 9.051772787302813, 9.054982526543846,
9.054982526543846
2.188360418259918, 2.5113130710591616, 2.5113130710591616, 1.685827353160205,
1.6687719892662431, 1.6687719892662431, 2.1668509663428335,
2.1667849760982665, 2.1667849760982665
)
)
expect_equal(observed, expected)
Expand All @@ -240,7 +235,7 @@ test_that("Milestone", {
test_that("WLR with fh(0, 0.5) test at IA1, WLR with mb(6, Inf) at IA2, and milestone test at FA", {
ia1_test <- create_test(wlr, weight = fh(rho = 0, gamma = 0.5))
ia2_test <- create_test(wlr, weight = mb(delay = 6, w_max = Inf))
fa_test <- create_test(milestone, ms_time = 10)
fa_test <- create_test(milestone, ms_time = 10, test_type = "naive")

observed <- sim_gs_n(
n_sim = 3,
Expand All @@ -264,20 +259,17 @@ test_that("WLR with fh(0, 0.5) test at IA1, WLR with mb(6, Inf) at IA2, and mile
-15.500239367897708, -44.437051762182506, 0.11738941400903585,
-12.664624037110103, -41.66249375734963, 0.1519773404060174
),
se = I(list(
4.081359229309616, 11.636448672437368,
c(0.034952703615152854, 0.03484070894801079), 4.299539499761723,
11.272930548434758, c(0.035432630739150366, 0.034912158581439694),
4.02917790229253, 11.25721499206715,
c(0.03540131462139614, 0.034738243333119145)
)),
se = c(
4.081359229309616, 11.636448672437368, 0.06979341256316365, 4.299539499761723,
11.272930548434758, 0.07034478932059006, 4.02917790229253, 11.25721499206715,
0.07013955795451529
),
z = c(
-4.149161171743935, -4.738039225196407, 12.078380683791904,
-3.605092910242299, -3.9419254444313574, 5.457930240636103,
-3.1432278107909206, -3.7009592325196583, 9.054982526543846
-4.149161171743935, -4.738039225196407, 2.5113130710591616,
-3.605092910242299, -3.9419254444313574, 1.6687719892662431,
-3.1432278107909206, -3.7009592325196583, 2.1667849760982665
)
)
class(expected$se) <- NULL # I() adds the class "AsIs"
expect_equal(observed, expected)
})

Expand Down Expand Up @@ -385,7 +377,7 @@ test_that("sim_gs_n() requires a test for each cutting", {
test_that("sim_gs_n() can combine wlr(), rmst(), and milestone() tests", {
test_cut1 <- create_test(wlr, weight = fh(rho = 0, gamma = 0))
test_cut2 <- create_test(rmst, tau = 20)
test_cut3 <- create_test(milestone, ms_time = 10)
test_cut3 <- create_test(milestone, ms_time = 10, test_type = "naive")

observed <- sim_gs_n(
n_sim = 3,
Expand All @@ -409,20 +401,17 @@ test_that("sim_gs_n() can combine wlr(), rmst(), and milestone() tests", {
-26.84871111584948, 2.3996923551365086, 0.11738941400903585,
-23.063020152157016, 2.4481174776559786, 0.1519773404060174
),
se = I(list(
7.521418120132856, 0.7147367073498636,
c(0.034952703615152854, 0.03484070894801079), 7.7214837796562,
0.7282783320819864, c(0.035432630739150366, 0.034912158581439694),
7.498065002594769, 0.7416397937499536,
c(0.03540131462139614, 0.034738243333119145)
)),
se = c(
7.521418120132856, 0.7147367073498636, 0.06979341256316365, 7.7214837796562,
0.7282783320819864, 0.07034478932059006, 7.498065002594769,
0.7416397937499536, 0.07013955795451529
),
z = c(
-3.7486049782713247, 3.991862864282945, 12.078380683791904,
-3.4771440155825752, 3.2950209410683957, 5.457930240636103,
-3.075862925191481, 3.3009521580248022, 9.054982526543846
-3.7486049782713247, 3.991862864282945, 2.5113130710591616,
-3.4771440155825752, 3.2950209410683957, 1.6687719892662431,
-3.075862925191481, 3.3009521580248022, 2.1667849760982665
)
)
class(expected$se) <- NULL # I() adds the class "AsIs"
expect_equal(observed, expected)
})

Expand Down

0 comments on commit a6dc71a

Please sign in to comment.