Skip to content

Correct the IA1 crossing probability under H0 for WLR designs #557

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions R/to_integer.R
Original file line number Diff line number Diff line change
Expand Up @@ -415,14 +415,16 @@ to_integer.gs_design <- function(x, round_up_final = TRUE, ratio = x$input$ratio

# ensure info0 is based on integer sample size calculation
# as as they become a slight different number due to the `enroll_rate`
q_e <- ratio / (1 + ratio)
q_c <- 1 - q_e
info_with_new_event$info0 <- event_new * q_e * q_c

# ensure info is based on integer sample size calculation
# as as they become a slight different number due to the `enroll_rate`
q <- event_new / event
info_with_new_event$info <- x$analysis$info * q
if (is_ahr) {
q_e <- ratio / (1 + ratio)
q_c <- 1 - q_e
info_with_new_event$info0 <- event_new * q_e * q_c

# ensure info is based on integer sample size calculation
# as as they become a slight different number due to the `enroll_rate`
q <- event_new / event
info_with_new_event$info <- x$analysis$info * q
}

# update timing
upar_new$timing <- info_with_new_event$info0 / max(info_with_new_event$info0)
Expand Down
24 changes: 21 additions & 3 deletions tests/testthat/test-developer-to_integer.R
Original file line number Diff line number Diff line change
Expand Up @@ -250,14 +250,32 @@ test_that("Validate the sample size rounding under unequal randomization (3:2) f
})

test_that("Validate the boundary is symmetric in symmetric designs.", {
x <- gs_design_ahr(analysis_time = 36, info_frac = 1:3/3,
x <- gs_design_ahr(analysis_time = 36, info_frac = 1:3/3,
upper = gs_spending_bound,
upar = list(sf = gsDesign::sfLDOF, total_spend = 0.025),
lower = gs_spending_bound,
lpar = list(sf = gsDesign::sfLDOF, total_spend = 0.025),
binding = TRUE, h1_spending = FALSE) %>%
to_integer()
expect_equal(x$bound$z[x$bound$bound == "upper"],

expect_equal(x$bound$z[x$bound$bound == "upper"],
-x$bound$z[x$bound$bound == "lower"])
})

test_that("verify the crossing prob of a MB design at IA1 under null", {
x <- gs_power_wlr(enroll_rate = define_enroll_rate(duration = 12, rate = 35.8),
fail_rate = define_fail_rate(duration = c(4, 100),
fail_rate = log(2)/12,
dropout_rate = 0.001,
hr = c(1, 0.6)),
analysis_time = c(20, 28, 36),
weight = list(method = "mb", param = list(tau = NULL, w_max = 2)),
upper = gs_spending_bound,
upar = list(sf = gsDesign::sfLDOF, total_spend = 0.025),
lpar = rep(-Inf, 3),
lower = gs_b,
test_lower = FALSE) |> to_integer()

expect_equal((x$bounds |> filter(bound == "upper", analysis == 1))$probability0,
sfLDOF(alpha = .025, t = x$analysis$info_frac0)$spend[1])
})