|
37 | 37 | #' Importantly, note that the simulated data set is always passed as the first |
38 | 38 | #' positional argument to each test function provided. |
39 | 39 | #' @param cut A list of cutting functions created by [create_cut()], see |
40 | | -#' examples. |
| 40 | +#' examples. Alternatively, if cut is \code{NULL} (the default) and a design |
| 41 | +#' object is provided via the argument `original_design`, the cut functions |
| 42 | +#' are automatically created from this object. |
41 | 43 | #' @param original_design A design object from the gsDesign2 package, which is required when users |
42 | 44 | #' want to calculate updated bounds. The default is NULL leaving the updated bounds uncalculated. |
43 | 45 | #' @param ia_alpha_spending Spend alpha at interim analysis based on |
@@ -319,6 +321,10 @@ sim_gs_n <- function( |
319 | 321 | message("The updated bound is currently only provided for logrank test.") |
320 | 322 | } |
321 | 323 |
|
| 324 | + # Create cut functions from the original design (if provided) by default |
| 325 | + if (is.null(cut)) cut <- cut_from_design(original_design) |
| 326 | + if (is.null(cut)) stop("Please provide the cutting for each analysis.") |
| 327 | + |
322 | 328 | # parallel computation message for backends ---- |
323 | 329 | if (!is(plan(), "sequential")) { |
324 | 330 | # future backend |
@@ -505,6 +511,19 @@ create_cut <- function(...) { |
505 | 511 | } |
506 | 512 | } |
507 | 513 |
|
| 514 | +# Create cut functions from the design object `x`, e.g., gsDesign2::gs_design_ahr() |
| 515 | +cut_from_design <- function(x) { |
| 516 | + if (is.null(x)) return() |
| 517 | + k <- nrow(x$analysis) |
| 518 | + lapply(seq_len(k), function(i) { |
| 519 | + if (is.null(x$input$analysis_time)) { |
| 520 | + create_cut(target_event_overall = x$analysis$event[i]) |
| 521 | + } else { |
| 522 | + create_cut(planned_calendar_time = x$analysis$time[i]) |
| 523 | + } |
| 524 | + }) |
| 525 | +} |
| 526 | + |
508 | 527 | #' Create a cutting test function |
509 | 528 | #' |
510 | 529 | #' Create a cutting test function for use with [sim_gs_n()] |
|
0 commit comments