Skip to content

Commit 0b37864

Browse files
Merge pull request #592 from jdblischak/text-summary-fixed-design
Update text_summary() to support fixed designs from gs_design_ahr()
2 parents 5103d9c + 6b6c5cf commit 0b37864

File tree

2 files changed

+34
-13
lines changed

2 files changed

+34
-13
lines changed

R/text_summary.R

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,15 @@
6363
#' fail_rate = log(2) / 10, dropout_rate = 0.001),
6464
#' info_frac = 1:3/3, test_lower = FALSE) |>
6565
#' text_summary()
66+
#'
67+
#' # Text summary of a fixed design created with gs_design_ahr()
68+
#' x <- gs_design_ahr(
69+
#' upper = gs_b,
70+
#' lower = gs_b,
71+
#' upar = qnorm(1 - 0.025),
72+
#' lpar = -Inf
73+
#' )
74+
#' x |> text_summary()
6675
text_summary <- function(x, information = FALSE, time_unit = "months") {
6776

6877
n_analysis <- nrow(x$analysis)
@@ -175,26 +184,29 @@ text_summary <- function(x, information = FALSE, time_unit = "months") {
175184
# Add enrollment and study duration
176185
# ---------------------------------------- #
177186
out <- paste(out, ". Enrollment and total study durations are assumed to be ", round(sum(x$enroll_rate$duration), 1),
178-
" and ", round(max(x$analysis$time), 1), " ", time_unit, ", respectively",
187+
" and ", round(max(x$analysis$time), 1), " ", time_unit, ", respectively.",
179188
sep = "")
180189

181190
# ---------------------------------------- #
182191
# Add upper bounds derivation
183192
# ---------------------------------------- #
184-
if (identical(x$input$upper, gs_spending_bound) && identical(x$input$lower, gs_spending_bound) &&
185-
identical(x$input$upar, x$input$lpar) && x$input$binding && !x$input$h1_spending) {
186-
out <- paste(out, ". Bounds derived using a ", sep = "")
187-
} else {
188-
out <- paste(out, ". Efficacy bounds derived using a", sep = "")
189-
}
193+
# A fixed design with one analysis has no bounds
194+
if (n_analysis > 1) {
195+
if (identical(x$input$upper, gs_spending_bound) && identical(x$input$lower, gs_spending_bound) &&
196+
identical(x$input$upar, x$input$lpar) && x$input$binding && !x$input$h1_spending) {
197+
out <- paste(out, " Bounds derived using a ", sep = "")
198+
} else {
199+
out <- paste(out, " Efficacy bounds derived using a", sep = "")
200+
}
190201

191-
analysis_seq <- c(paste("IA", 1:(n_analysis - 1), sep = ""), "FA")
192-
sfu <- get_sf(x$input$upar$sf)
193-
upper_text <- sfu(alpha = x$input$upar$total_spend, t = x$analysis$info_frac, param = x$input$upar$param)
194-
upper_tested <- if (!all(x$input$test_upper)) {
195-
paste(", tested at", paste("tested at", paste(analysis_seq[x$input$test_upper], collapse = ", ")))
202+
analysis_seq <- c(paste("IA", 1:(n_analysis - 1), sep = ""), "FA")
203+
sfu <- get_sf(x$input$upar$sf)
204+
upper_text <- sfu(alpha = x$input$upar$total_spend, t = x$analysis$info_frac, param = x$input$upar$param)
205+
upper_tested <- if (!all(x$input$test_upper)) {
206+
paste(", tested at", paste("tested at", paste(analysis_seq[x$input$test_upper], collapse = ", ")))
207+
}
208+
out <- paste(out, " ", summary(upper_text), upper_tested, ".", sep = "")
196209
}
197-
out <- paste(out, " ", summary(upper_text), upper_tested, ".", sep = "")
198210

199211
# ---------------------------------------- #
200212
# Add lower bounds derivation

man/text_summary.Rd

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

0 commit comments

Comments
 (0)