|
118 | 118 | #' |
119 | 119 | #' # Alpha is updated to 0.05 |
120 | 120 | #' gs_update_ahr(x = x, alpha = 0.05) |
| 121 | +#' |
| 122 | +#' # ------------------------------------------------- # |
| 123 | +#' # Two-sided asymmetric stratified design, |
| 124 | +#' # beta-spending with non-binding lower bound |
| 125 | +#' # ------------------------------------------------- # |
| 126 | +#' enroll_rate <- define_enroll_rate(stratum = c("A", "B"), duration = c(12, 12), rate = c(1, 1)) |
| 127 | +#' |
| 128 | +#' # We assumme there are 2 strata, "A" and "B". |
| 129 | +#' # For each stratum, there are delayed effect for the first 3 months. |
| 130 | +#' # After the delayed effect, the HR is 0.8 for stratum A and 0.5 for stratum B. |
| 131 | +#' fail_rate <- define_fail_rate(stratum = c("A", "A", "B", "B"), |
| 132 | +#' duration = c(3, Inf, 3, Inf), |
| 133 | +#' fail_rate = log(2) / c(9, 9, 9, 15), |
| 134 | +#' hr = c(1, 0.8, 1, 0.5), |
| 135 | +#' dropout_rate = rep(0.001, 4)) |
| 136 | +#' |
| 137 | +#' # The original design assumes there are 2 IAs and 1 FA cutting by calendar time. |
| 138 | +#' # The efficacy testing is conducted at IA2 and FA. |
| 139 | +#' # The futility testing is conducted at IA1. |
| 140 | +#' x <- gs_design_ahr(enroll_rate = enroll_rate, |
| 141 | +#' fail_rate = fail_rate, |
| 142 | +#' alpha = 0.0125, |
| 143 | +#' beta = 0.1, |
| 144 | +#' analysis = c(20, 28, 36), |
| 145 | +#' upper = "gs_spending_bound", |
| 146 | +#' upar = list(sf = "sfLDOF", total_spend = 0.0125), |
| 147 | +#' lower = "gs_spending_bound", |
| 148 | +#' lpar = list(sf = "sfHSD", total_spend = 0.1, param = -8), |
| 149 | +#' test_upper = c(FALSE, TRUE, TRUE), |
| 150 | +#' test_lower = c(TRUE, FALSE, FALSE)) |> to_integer() |
| 151 | +#' |
| 152 | +#' # At time of analysis |
| 153 | +#' # For IA1, |
| 154 | +#' # - There are 70 events observed during the delayed effect period for stratum A. |
| 155 | +#' # - There are 150 events observed after the delayed effect period for stratum A. |
| 156 | +#' # - There are 75 events observed during the delayed effect period for stratum B. |
| 157 | +#' # - There are 90 events observed after the delayed effect period for stratum B. |
| 158 | +#' # For IA2, |
| 159 | +#' # - There are 75 events observed during the delayed effect period for stratum A. |
| 160 | +#' # - There are 210 events observed after the delayed effect period for stratum A. |
| 161 | +#' # - There are 76 events observed during the delayed effect period for stratum B. |
| 162 | +#' # - There are 136 events observed after the delayed effect period for stratum B. |
| 163 | +#' # For FA, |
| 164 | +#' # - There are 77 events observed during the delayed effect period for stratum A. |
| 165 | +#' # - There are 245 events observed after the delayed effect period for stratum A. |
| 166 | +#' # - There are 77 events observed during the delayed effect period for stratum B. |
| 167 | +#' # - There are 170 events observed after the delayed effect period for stratum B. |
| 168 | +#' event_tbl <- data.frame(analysis = c(1, 1, 1, 1, |
| 169 | +#' 2, 2, 2, 2, |
| 170 | +#' 3, 3, 3, 3), |
| 171 | +#' stratum = c("A", "A", "B", "B", # IA1 |
| 172 | +#' "A", "A", "B", "B", # IA2 |
| 173 | +#' "A", "A", "B", "B"),# FA |
| 174 | +#' # event per interval per stratum at IA1 |
| 175 | +#' event = c(70, 150, 75, 90, |
| 176 | +#' # event per interval per stratum at IA2 |
| 177 | +#' 75, 210, 76, 136, |
| 178 | +#' # event per interval per stratum at FA |
| 179 | +#' 77, 245, 77, 170)) |
| 180 | +#' observed_event <- (event_tbl |> dplyr::group_by(analysis) |> dplyr::summarize(x = sum(event)))$x |
| 181 | +#' |
| 182 | +#' ustime <- pmin(x$analysis$event, |
| 183 | +#' observed_event) / x$analysis$event[3] |
| 184 | +#' ustime[3] <- 1 |
| 185 | +#' lstime <- ustime |
| 186 | +#' |
| 187 | +#' xu <- gs_update_ahr(x = x, |
| 188 | +#' alpha = 0.015, |
| 189 | +#' ustime = ustime, |
| 190 | +#' lstime = lstime, |
| 191 | +#' event_tbl = event_tbl |
| 192 | +#' ) |
121 | 193 | gs_update_ahr <- function( |
122 | 194 | x = NULL, |
123 | 195 | alpha = NULL, |
|
0 commit comments