Skip to content

Add the h1_spending argument to gs_power_wlr #561

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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -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")),
Expand Down
20 changes: 14 additions & 6 deletions R/gs_power_wlr.R
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -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,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since all the other arguments are on their own line, I recommend keeping this consistent with the surrounding code and moving theta0 and theta1 to new lines

info = x$info,
info0 = x$info0,
info1 = x$info,
info1 = info1,
info_scale = info_scale,
binding = binding,
upper = upper,
Expand All @@ -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,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto above comment

info = x$info0,
info0 = x$info0,
info1 = x$info,
info1 = info1,
info_scale = info_scale,
binding = binding,
upper = upper,
Expand Down
8 changes: 8 additions & 0 deletions man/gs_power_wlr.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions tests/testthat/test-developer-gs_power_wlr.R
Original file line number Diff line number Diff line change
@@ -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)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Love the test! For completeness, would it also make sense to have a test with h1_spending = TRUE to demonstrate that in that case the upper and lower bounds are not equal?


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

})
Loading