diff --git a/DESCRIPTION b/DESCRIPTION index a698cbf7..72535996 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: gsDesign2 Title: Group Sequential Design with Non-Constant Effect -Version: 1.1.5 +Version: 1.1.5.1 Authors@R: c( person("Keaven", "Anderson", email = "keaven_anderson@merck.com", role = c("aut")), person("Yujie", "Zhao", email = "yujie.zhao@merck.com", role = c("aut", "cre")), diff --git a/R/gs_power_wlr.R b/R/gs_power_wlr.R index 88bce732..68e0718e 100644 --- a/R/gs_power_wlr.R +++ b/R/gs_power_wlr.R @@ -169,6 +169,7 @@ gs_power_wlr <- function(enroll_rate = define_enroll_rate(duration = c(2, 2, 10) event = c(30, 40, 50), analysis_time = NULL, binding = FALSE, + h1_spending = TRUE, upper = gs_spending_bound, lower = gs_spending_bound, upar = list(sf = gsDesign::sfLDOF, total_spend = 0.025), @@ -208,12 +209,21 @@ gs_power_wlr <- function(enroll_rate = define_enroll_rate(duration = c(2, 2, 10) interval = interval ) + # set up H1 spending + if (h1_spending) { + theta1 <- x$theta + info1 <- x$info + } else { + theta1 <- 0 + info1 <- x$info0 + } + # Given the above statistical information calculate the power ---- y_h1 <- gs_power_npe( - theta = x$theta, + theta = x$theta, theta0 = 0, theta1 = theta1, info = x$info, info0 = x$info0, - info1 = x$info, + info1 = info1, info_scale = info_scale, binding = binding, upper = upper, @@ -227,12 +237,10 @@ gs_power_wlr <- function(enroll_rate = define_enroll_rate(duration = c(2, 2, 10) ) y_h0 <- gs_power_npe( - theta = 0, - theta0 = 0, - theta1 = x$theta, + theta = 0, theta0 = 0, theta1 = theta1, info = x$info0, info0 = x$info0, - info1 = x$info, + info1 = info1, info_scale = info_scale, binding = binding, upper = upper, diff --git a/man/gs_power_wlr.Rd b/man/gs_power_wlr.Rd index 19a5829f..078a7a2d 100644 --- a/man/gs_power_wlr.Rd +++ b/man/gs_power_wlr.Rd @@ -11,6 +11,7 @@ gs_power_wlr( event = c(30, 40, 50), analysis_time = NULL, binding = FALSE, + h1_spending = TRUE, upper = gs_spending_bound, lower = gs_spending_bound, upar = list(sf = gsDesign::sfLDOF, total_spend = 0.025), @@ -39,6 +40,13 @@ gs_power_wlr( \item{binding}{Indicator of whether futility bound is binding; default of \code{FALSE} is recommended.} +\item{h1_spending}{Indicator that lower bound to be set by spending +under alternate hypothesis (input \code{fail_rate}) +if spending is used for lower bound. +If this is \code{FALSE}, then the lower bound spending is under the null hypothesis. +This is for two-sided symmetric or asymmetric testing under the null hypothesis; +See \href{https://merck.github.io/gsDesign2/articles/story-seven-test-types.html}{this vignette}.} + \item{upper}{Function to compute upper bound. \itemize{ \item \code{gs_spending_bound()}: alpha-spending efficacy bounds. diff --git a/tests/testthat/test-developer-gs_power_wlr.R b/tests/testthat/test-developer-gs_power_wlr.R new file mode 100644 index 00000000..9e0bf227 --- /dev/null +++ b/tests/testthat/test-developer-gs_power_wlr.R @@ -0,0 +1,13 @@ +test_that("Validate 2-sided symetric design", { + x <- gs_power_wlr(enroll_rate = define_enroll_rate(duration = 12, rate = 50), + analysis_time = NULL, event = c(100, 200, 300), + 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) + + expect_equal(x$bound$z[x$bound$bound == "upper"], + -x$bound$z[x$bound$bound == "lower"]) + +})