Skip to content

Commit 50963fc

Browse files
committed
add integer argument to gs_power_ahr
1 parent 6ecd7bb commit 50963fc

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

R/gs_power_ahr.R

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,12 @@
5353
#' @param tol Tolerance parameter for boundary convergence (on Z-scale).
5454
#' @param interval An interval that is presumed to include the time at which
5555
#' expected event count is equal to targeted event.
56+
#' @param integer Logical value integer whether it is an integer design
57+
#' (i.e., integer sample size and events) or not. This argument is commonly
58+
#' used when creating integer design via [to_integer()].
5659
#'
57-
#' @return A tibble with columns `Analysis`, `Bound`, `Z`, `Probability`,
58-
#' `theta`, `Time`, `AHR`, `Events`.
60+
#' @return A tibble with columns `analysis`, `bound`, `z`, `probability`,
61+
#' `theta`, `time`, `ahr`, `event`.
5962
#' Contains a row for each analysis and each bound.
6063
#'
6164
#' @details
@@ -159,7 +162,8 @@ gs_power_ahr <- function(
159162
info_scale = c("h0_h1_info", "h0_info", "h1_info"),
160163
r = 18,
161164
tol = 1e-6,
162-
interval = c(.01, 1000)) {
165+
interval = c(.01, 1000),
166+
integer = FALSE) {
163167
# Get the number of analysis
164168
n_analysis <- max(length(event), length(analysis_time), na.rm = TRUE)
165169

@@ -198,8 +202,7 @@ gs_power_ahr <- function(
198202
)
199203

200204
# if both events and sample size are integers, then elaborate the info and info0
201-
sample_size <- sum(enroll_rate$duration * enroll_rate$rate)
202-
if (abs(sample_size - round(sample_size)) < 1e-5 && all(abs(event - round(event)) < 1e-5)) {
205+
if (integer) {
203206

204207
# elaborate info0
205208
q_e <- ratio / (1 + ratio)

R/to_integer.R

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,8 @@ to_integer.gs_design <- function(x, sample_size = TRUE, ...) {
350350
test_lower = x$input$test_lower,
351351
binding = x$input$binding,
352352
info_scale = x$input$info_scale, r = x$input$r, tol = x$input$tol,
353-
interval = c(0.01, max(x$analysis$time) + 100)
353+
interval = c(0.01, max(x$analysis$time) + 100),
354+
integer = TRUE
354355
)
355356
if (is_wlr) power_args[c("weight", "approx")] <- x$input[c("weight", "approx")]
356357
x_new <- do.call(if (is_wlr) gs_power_wlr else gs_power_ahr, power_args)

0 commit comments

Comments
 (0)