|
63 | 63 | #' fail_rate = log(2) / 10, dropout_rate = 0.001), |
64 | 64 | #' info_frac = 1:3/3, test_lower = FALSE) |> |
65 | 65 | #' 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() |
66 | 75 | text_summary <- function(x, information = FALSE, time_unit = "months") { |
67 | 76 |
|
68 | 77 | n_analysis <- nrow(x$analysis) |
@@ -175,26 +184,29 @@ text_summary <- function(x, information = FALSE, time_unit = "months") { |
175 | 184 | # Add enrollment and study duration |
176 | 185 | # ---------------------------------------- # |
177 | 186 | 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.", |
179 | 188 | sep = "") |
180 | 189 |
|
181 | 190 | # ---------------------------------------- # |
182 | 191 | # Add upper bounds derivation |
183 | 192 | # ---------------------------------------- # |
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 | + } |
190 | 201 |
|
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 = "") |
196 | 209 | } |
197 | | - out <- paste(out, " ", summary(upper_text), upper_tested, ".", sep = "") |
198 | 210 |
|
199 | 211 | # ---------------------------------------- # |
200 | 212 | # Add lower bounds derivation |
|
0 commit comments