@@ -662,6 +662,8 @@ test_that("create_cut() can accept variables as arguments", {
662662})
663663
664664test_that(" Updating bounds changes the simulation results" , {
665+ skip_if_not_installed(" gsDesign2" )
666+
665667 x <- gsDesign2 :: gs_design_ahr(analysis_time = 1 : 3 * 12 ) | >
666668 gsDesign2 :: to_integer()
667669
@@ -702,7 +704,56 @@ test_that("Updating bounds changes the simulation results", {
702704 updated_upper_bound = c(3.870248012128966 , 2.3867954048423474 , 2.0074221828251764 ),
703705 updated_lower_bound = c(- 1.6671962217546439 , 0.9631736579151768 , 2.1126105535696467 )
704706 )
705- observed <- run2 [, c(" planed_upper_bound " , " planed_lower_bound " ,
707+ observed <- run2 [, c(" planned_upper_bound " , " planned_lower_bound " ,
706708 " updated_upper_bound" , " updated_lower_bound" )]
707709 expect_equal(observed , expected , ignore_attr = TRUE )
708710})
711+
712+ test_that(" sim_gs_n() can update bounds even when some are missing" , {
713+ # https://github.com/Merck/simtrial/issues/335
714+
715+ skip_if_not_installed(" gsDesign2" )
716+
717+ # futility - IA1; efficacy - IA2 & FA
718+ x <- gsDesign2 :: gs_design_ahr(
719+ alpha = 0.025 ,
720+ beta = 0.1 ,
721+ analysis_time = 1 : 3 * 12 ,
722+ upper = gsDesign2 :: gs_spending_bound ,
723+ upar = list (sf = gsDesign :: sfLDOF , total_spend = 0.025 ),
724+ test_upper = c(FALSE , TRUE , TRUE ),
725+ lower = gsDesign2 :: gs_spending_bound ,
726+ lpar = list (sf = gsDesign :: sfHSD , param = - 4 , total_spend = 0.01 ),
727+ test_lower = c(TRUE , FALSE , FALSE )
728+ ) | > gsDesign2 :: to_integer()
729+
730+ set.seed(1 )
731+ observed <- sim_gs_n(
732+ n_sim = 1 ,
733+ sample_size = max(x $ analysis $ n ),
734+ enroll_rate = x $ enroll_rate ,
735+ fail_rate = x $ fail_rate ,
736+ test = wlr ,
737+ weight = fh(rho = 0 , gamma = 0 ),
738+ cut = list (ia1 = create_cut(planned_calendar_time = x $ analysis $ time [1 ]),
739+ ia2 = create_cut(planned_calendar_time = x $ analysis $ time [2 ]),
740+ fa = create_cut(planned_calendar_time = x $ analysis $ time [3 ])),
741+ original_design = x )
742+
743+ expect_equal(
744+ observed $ planned_upper_bound ,
745+ c(NA , 2.35835648246416 , 2.00932773528063 )
746+ )
747+ expect_equal(
748+ observed $ planned_lower_bound ,
749+ c(- 2.31975897600847 , NA , NA )
750+ )
751+ expect_equal(
752+ observed $ updated_upper_bound ,
753+ c(Inf , 2.46416041021134 , 1.99094670148633 )
754+ )
755+ expect_equal(
756+ observed $ updated_lower_bound ,
757+ c(- 2.72847356838699 , - Inf , - Inf )
758+ )
759+ })
0 commit comments