Skip to content

Commit 0e21ca0

Browse files
authored
Merge pull request #518 from Merck/516-symmetric-design-issue-with-to_integer
Symmetric design issue with `to_integer`
2 parents 966a8e6 + d019698 commit 0e21ca0

File tree

6 files changed

+52
-8
lines changed

6 files changed

+52
-8
lines changed

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: gsDesign2
22
Title: Group Sequential Design with Non-Constant Effect
3-
Version: 1.1.3.2
3+
Version: 1.1.3.3
44
Authors@R: c(
55
person("Keaven", "Anderson", email = "[email protected]", role = c("aut")),
66
person("Yilong", "Zhang", email = "[email protected]", role = c("aut")),

R/gs_power_ahr.R

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,8 @@
122122
#' # Events = max(events, calculated events for targeted analysis_time)
123123
#' \donttest{
124124
#' gs_power_ahr(
125-
#' analysis_time = c(12, 24, 36),
126-
#' event = c(30, 40, 50),
125+
#' analysis_time = c(12, 24, 36),
126+
#' event = c(30, 40, 50), h1_spending = FALSE,
127127
#' binding = TRUE,
128128
#' upper = gs_spending_bound,
129129
#' upar = list(sf = gsDesign::sfLDOF, total_spend = 0.025),
@@ -152,6 +152,7 @@ gs_power_ahr <- function(
152152
test_upper = TRUE,
153153
ratio = 1,
154154
binding = FALSE,
155+
h1_spending = TRUE,
155156
info_scale = c("h0_h1_info", "h0_info", "h1_info"),
156157
r = 18,
157158
tol = 1e-6,
@@ -207,18 +208,26 @@ gs_power_ahr <- function(
207208
x$info <- x$info * q
208209
}
209210

211+
if (h1_spending) {
212+
theta1 <- x$theta
213+
info1 <- x$info
214+
} else {
215+
theta1 <- 0
216+
info1 <- x$info0
217+
}
218+
210219
# Given the above statistical information, calculate the power ----
211220
y_h1 <- gs_power_npe(
212-
theta = x$theta,
213-
info = x$info, info0 = x$info0, info1 = x$info, info_scale = info_scale,
221+
theta = x$theta, theta0 = 0, theta1 = theta1,
222+
info = x$info, info0 = x$info0, info1 = info1, info_scale = info_scale,
214223
upper = upper, upar = upar, test_upper = test_upper,
215224
lower = lower, lpar = lpar, test_lower = test_lower,
216225
binding = binding, r = r, tol = tol
217226
)
218227

219228
y_h0 <- gs_power_npe(
220-
theta = 0, theta0 = 0, theta1 = x$theta,
221-
info = x$info0, info0 = x$info0, info1 = x$info, info_scale = info_scale,
229+
theta = 0, theta0 = 0, theta1 = theta1,
230+
info = x$info0, info0 = x$info0, info1 = info1, info_scale = info_scale,
222231
upper = upper, upar = upar, test_upper = test_upper,
223232
lower = if (!two_sided) {
224233
gs_b

R/to_integer.R

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -468,6 +468,7 @@ to_integer.gs_design <- function(x, round_up_final = TRUE, ratio = x$input$ratio
468468
interval = c(0.01, max(x$analysis$time) + 100),
469469
integer = TRUE
470470
)
471+
if (is_ahr) power_args["h1_spending"] <- x$input["h1_spending"]
471472
if (is_wlr) power_args[c("weight", "approx")] <- x$input[c("weight", "approx")]
472473
x_new <- do.call(if (is_wlr) gs_power_wlr else gs_power_ahr, power_args)
473474
} else {

man/gs_power_ahr.Rd

Lines changed: 9 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/testthat/test-developer-gs_power_ahr.R

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,3 +138,16 @@ test_that("Use default lower, lpar and test_lower", {
138138
expect_error(gs_power_ahr(analysis_time = c(24, 36),
139139
event = c(50, 100)))
140140
})
141+
142+
test_that("Validate the boundary is symmetric in symmetric designs.", {
143+
x <- gs_design_ahr(analysis_time = 36, info_frac = 1:3/3,
144+
upper = gs_spending_bound,
145+
upar = list(sf = gsDesign::sfLDOF, total_spend = 0.025),
146+
lower = gs_spending_bound,
147+
lpar = list(sf = gsDesign::sfLDOF, total_spend = 0.025),
148+
binding = TRUE, h1_spending = FALSE) %>%
149+
to_integer()
150+
151+
expect_equal(x$bound$z[x$bound$bound == "upper"],
152+
-x$bound$z[x$bound$bound == "lower"])
153+
})

tests/testthat/test-developer-to_integer.R

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,3 +248,16 @@ test_that("Validate the sample size rounding under unequal randomization (3:2) f
248248
# error when ratio is negative
249249
expect_error(x |> to_integer(ratio = -2))
250250
})
251+
252+
test_that("Validate the boundary is symmetric in symmetric designs.", {
253+
x <- gs_design_ahr(analysis_time = 36, info_frac = 1:3/3,
254+
upper = gs_spending_bound,
255+
upar = list(sf = gsDesign::sfLDOF, total_spend = 0.025),
256+
lower = gs_spending_bound,
257+
lpar = list(sf = gsDesign::sfLDOF, total_spend = 0.025),
258+
binding = TRUE, h1_spending = FALSE) %>%
259+
to_integer()
260+
261+
expect_equal(x$bound$z[x$bound$bound == "upper"],
262+
-x$bound$z[x$bound$bound == "lower"])
263+
})

0 commit comments

Comments
 (0)