Skip to content

Commit c0a49e3

Browse files
Merge pull request #557 from Merck/534-correct-spending-in-gs_design_wlr
Correct the IA1 crossing probability under H0 for WLR designs
2 parents bf27245 + f2cd944 commit c0a49e3

File tree

2 files changed

+31
-11
lines changed

2 files changed

+31
-11
lines changed

R/to_integer.R

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -415,14 +415,16 @@ to_integer.gs_design <- function(x, round_up_final = TRUE, ratio = x$input$ratio
415415

416416
# ensure info0 is based on integer sample size calculation
417417
# as as they become a slight different number due to the `enroll_rate`
418-
q_e <- ratio / (1 + ratio)
419-
q_c <- 1 - q_e
420-
info_with_new_event$info0 <- event_new * q_e * q_c
421-
422-
# ensure info is based on integer sample size calculation
423-
# as as they become a slight different number due to the `enroll_rate`
424-
q <- event_new / event
425-
info_with_new_event$info <- x$analysis$info * q
418+
if (is_ahr) {
419+
q_e <- ratio / (1 + ratio)
420+
q_c <- 1 - q_e
421+
info_with_new_event$info0 <- event_new * q_e * q_c
422+
423+
# ensure info is based on integer sample size calculation
424+
# as as they become a slight different number due to the `enroll_rate`
425+
q <- event_new / event
426+
info_with_new_event$info <- x$analysis$info * q
427+
}
426428

427429
# update timing
428430
upar_new$timing <- info_with_new_event$info0 / max(info_with_new_event$info0)

tests/testthat/test-developer-to_integer.R

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -250,14 +250,32 @@ test_that("Validate the sample size rounding under unequal randomization (3:2) f
250250
})
251251

252252
test_that("Validate the boundary is symmetric in symmetric designs.", {
253-
x <- gs_design_ahr(analysis_time = 36, info_frac = 1:3/3,
253+
x <- gs_design_ahr(analysis_time = 36, info_frac = 1:3/3,
254254
upper = gs_spending_bound,
255255
upar = list(sf = gsDesign::sfLDOF, total_spend = 0.025),
256256
lower = gs_spending_bound,
257257
lpar = list(sf = gsDesign::sfLDOF, total_spend = 0.025),
258258
binding = TRUE, h1_spending = FALSE) %>%
259259
to_integer()
260-
261-
expect_equal(x$bound$z[x$bound$bound == "upper"],
260+
261+
expect_equal(x$bound$z[x$bound$bound == "upper"],
262262
-x$bound$z[x$bound$bound == "lower"])
263263
})
264+
265+
test_that("verify the crossing prob of a MB design at IA1 under null", {
266+
x <- gs_power_wlr(enroll_rate = define_enroll_rate(duration = 12, rate = 35.8),
267+
fail_rate = define_fail_rate(duration = c(4, 100),
268+
fail_rate = log(2)/12,
269+
dropout_rate = 0.001,
270+
hr = c(1, 0.6)),
271+
analysis_time = c(20, 28, 36),
272+
weight = list(method = "mb", param = list(tau = NULL, w_max = 2)),
273+
upper = gs_spending_bound,
274+
upar = list(sf = gsDesign::sfLDOF, total_spend = 0.025),
275+
lpar = rep(-Inf, 3),
276+
lower = gs_b,
277+
test_lower = FALSE) |> to_integer()
278+
279+
expect_equal((x$bounds |> filter(bound == "upper", analysis == 1))$probability0,
280+
sfLDOF(alpha = .025, t = x$analysis$info_frac0)$spend[1])
281+
})

0 commit comments

Comments
 (0)