|
| 1 | +#' Build a multi-stage group-sequential multi-arm clinical trial for a Poisson |
| 2 | +#' distributed primary outcome |
| 3 | +#' |
| 4 | +#' \code{build_gs_pois()} builds a multi-stage group-sequential multi-arm |
| 5 | +#' clinical trial design object assuming the primary outcome variable is |
| 6 | +#' Poisson distributed, like those returned by \code{\link{des_gs_pois}}. |
| 7 | +#' |
| 8 | +#' @param n1 A \code{\link{numeric}} indicating the chosen value for |
| 9 | +#' \ifelse{html}{\out{<i>n</i><sub>1</sub>}}{\eqn{n_1}}, the total sample size |
| 10 | +#' required in stage one of the trial. Defaults to \code{162}. |
| 11 | +#' @param n10 A \code{\link{numeric}} indicating the chosen value for |
| 12 | +#' \ifelse{html}{\out{<i>n</i><sub>10</sub>}}{\eqn{n_{10}}}, the sample size |
| 13 | +#' required in the control arm in stage one of the trial. Defaults to \code{54}. |
| 14 | +#' @param e A \code{\link{numeric}} \code{\link{vector}} indicating the chosen |
| 15 | +#' value for \ifelse{html}{\out{<b><i>e</i></b>}}{\eqn{\bold{e}}}, the efficacy |
| 16 | +#' (upper) stopping boundaries. Defaults to \code{c(2.42, 2.42)}. |
| 17 | +#' @param f A \code{\link{numeric}} \code{\link{vector}} indicating the chosen |
| 18 | +#' value for \ifelse{html}{\out{<b><i>f</i></b>}}{\eqn{\bold{f}}}, the futility |
| 19 | +#' (lower) stopping boundaries. Defaults to \code{c(-2.42, 2.42)}. |
| 20 | +#' @param K A \code{\link{numeric}} indicating the chosen value for |
| 21 | +#' \ifelse{html}{\out{<i>K</i>}}{\eqn{\bold{K}}}, the (initial) number of |
| 22 | +#' experimental treatment arms. Defaults to \code{2}. |
| 23 | +#' @param alpha A \code{\link{numeric}} indicating the chosen value for |
| 24 | +#' \ifelse{html}{\out{<i>α</i>}}{\eqn{\alpha}}, the significance level |
| 25 | +#' (family-wise error-rate). Defaults to \code{0.025}. |
| 26 | +#' @param beta A \code{\link{numeric}} indicating the chosen value for |
| 27 | +#' \ifelse{html}{\out{<i>β</i>}}{\eqn{\beta}}, used in the definition of |
| 28 | +#' the desired power. Defaults to \code{0.1}. |
| 29 | +#' @param lambda0 A \code{\link{numeric}} indicating the chosen value for |
| 30 | +#' \ifelse{html}{\out{<i>λ</i><sub>0</sub>}}{\eqn{\lambda_0}}, the |
| 31 | +#' event rate in the control arm. Defaults to \code{5}. |
| 32 | +#' @param delta1 A \code{\link{numeric}} indicating the chosen value for |
| 33 | +#' \ifelse{html}{\out{<i>δ</i><sub>1</sub>}}{\eqn{\delta_1}}, the |
| 34 | +#' 'interesting' treatment effect. Defaults to \code{1}. |
| 35 | +#' @param delta0 A \code{\link{numeric}} indicating the chosen value for |
| 36 | +#' \ifelse{html}{\out{<i>δ</i><sub>0</sub>}}{\eqn{\delta_0}}, the |
| 37 | +#' 'uninteresting' treatment effect. Defaults to \code{0}. |
| 38 | +#' @param ratio A \code{\link{numeric}} indicating the chosen value for |
| 39 | +#' \ifelse{html}{\out{<i>r</i>}}{\eqn{r}}, the stage-wise allocation ratio to |
| 40 | +#' present experimental arms. Defaults to \code{1}. |
| 41 | +#' @param power A \code{\link{character}} string indicating the chosen type of |
| 42 | +#' power to design the trial for. Can be \code{"disjunctive"} or |
| 43 | +#' \code{"marginal"}. Defaults to \code{"marginal"}. |
| 44 | +#' @param stopping A \code{\link{character}} string indicating the chosen type |
| 45 | +#' of stopping rule. Can be \code{"separate"} or \code{"simultaneous"}. Defaults |
| 46 | +#' to \code{"simultaneous"}. |
| 47 | +#' @param type A \code{\link{character}} string indicating the choice for the |
| 48 | +#' stage-wise sample size. Can be \code{"variable"} or \code{"fixed"}. Defaults |
| 49 | +#' to \code{"variable"}. |
| 50 | +#' @param summary A \code{\link{logical}} variable indicating whether a summary |
| 51 | +#' of the function's progress should be printed to the console. Defaults to |
| 52 | +#' \code{FALSE}. |
| 53 | +#' @return A \code{\link{list}}, with additional class |
| 54 | +#' \code{"multiarm_des_gs_pois"}, containing the following elements: |
| 55 | +#' \itemize{ |
| 56 | +#' \item A \code{\link{tibble}} in the slot \code{$opchar} summarising the |
| 57 | +#' operating characteristics of the identified design. |
| 58 | +#' \item A \code{\link{tibble}} in the slot \code{$pmf_N} summarising the |
| 59 | +#' probability mass function of the random required sample size under key |
| 60 | +#' scenarios. |
| 61 | +#' \item A \code{\link{numeric}} in the slot \code{$maxN} specifying |
| 62 | +#' \ifelse{html}{\out{max <i>N</i>}}{max \eqn{N}}, the trial's maximum required |
| 63 | +#' sample size. |
| 64 | +#' \item A \code{\link{numeric}} in the slot \code{$n_factor}, for internal use |
| 65 | +#' in other functions. |
| 66 | +#' \item Each of the input variables. |
| 67 | +#' } |
| 68 | +#' @examples |
| 69 | +#' # The design for the default parameters |
| 70 | +#' des <- build_gs_pois() |
| 71 | +#' @seealso \code{\link{des_gs_pois}}, \code{\link{gui}}, |
| 72 | +#' \code{\link{opchar_gs_pois}}, \code{\link{plot.multiarm_des_gs_pois}}, |
| 73 | +#' \code{\link{sim_gs_pois}}. |
| 74 | +#' @export |
| 75 | +build_gs_pois <- function(n1 = 231, n10 = 77, e = c(2.42, 2.42), |
| 76 | + f = c(-2.42, 2.42), K = 2, alpha = 0.025, beta = 0.1, |
| 77 | + lambda0 = 5, delta1 = 1, delta0 = 0, ratio = 1, |
| 78 | + power = "marginal", stopping = "simultaneous", |
| 79 | + type = "variable", summary = F) { |
| 80 | + |
| 81 | + ##### Check input variables ################################################## |
| 82 | + |
| 83 | + #check_n1_n10(n1, n10, "n1", "n10", int = F) |
| 84 | + #check_ef(e, f, "e", "f") |
| 85 | + J <- length(e) |
| 86 | + K <- check_integer_range(K, "K", c(1, Inf), 1) |
| 87 | + check_real_range_strict(alpha, "alpha", c(0, 1), 1) |
| 88 | + check_real_range_strict(beta, "beta", c(0, 1), 1) |
| 89 | + check_real_range_strict(lambda0, "lambda0", c(0, Inf), 1) |
| 90 | + check_delta0_delta1(delta0, delta1, "delta0", "delta1", lambda0 = lambda0, |
| 91 | + name_lambda0 = "lambda0") |
| 92 | + check_real_range_strict(ratio, "ratio", c(0, Inf), 1) |
| 93 | + check_belong(power, "power", c("conjunctive", "disjunctive", "marginal"), 1) |
| 94 | + check_belong(stopping, "stopping", c("simultaneous", "separate"), 1) |
| 95 | + check_belong(type, "type", c("fixed", "variable"), 1) |
| 96 | + check_logical(summary, "summary") |
| 97 | + |
| 98 | + ##### Print summary ########################################################## |
| 99 | + |
| 100 | + if (summary) { |
| 101 | + #summary_build_gs_pois(n1, n10, e, f, K, alpha, beta, lambda0, delta1, |
| 102 | + # delta0, ratio, power, stopping, type) |
| 103 | + message("") |
| 104 | + } |
| 105 | + |
| 106 | + ##### Perform main computations ############################################## |
| 107 | + |
| 108 | + if (summary) { |
| 109 | + message(" Building outputs..") |
| 110 | + } |
| 111 | + integer <- all(c(n1, n10)%%1 == 0) |
| 112 | + if (type == "variable") { |
| 113 | + n_factor <- n10 |
| 114 | + } else { |
| 115 | + n_factor <- n1 |
| 116 | + } |
| 117 | + comp <- components_gs_init(alpha, beta, delta0, delta1, NA, NA, NA, NA, |
| 118 | + integer, J, K, power, ratio, stopping, |
| 119 | + summary, type, lambda0 = lambda0, |
| 120 | + n_factor = n_factor, f = f, e = e) |
| 121 | + tau <- rbind(numeric(K), rep(delta1, K), |
| 122 | + matrix(delta0, K, K) + (delta1 - delta0)*diag(K)) |
| 123 | + comp <- components_gs_update(comp, tau, |
| 124 | + lambda = cbind(lambda0, tau + lambda0)) |
| 125 | + comp <- opchar_gs_internal(comp) |
| 126 | + |
| 127 | + ##### Outputting ############################################################# |
| 128 | + |
| 129 | + if (summary) { |
| 130 | + message("..outputting.") |
| 131 | + } |
| 132 | + output <- list(alpha = alpha, |
| 133 | + beta = beta, |
| 134 | + delta0 = delta0, |
| 135 | + delta1 = delta1, |
| 136 | + e = comp$e, |
| 137 | + efix = NA, |
| 138 | + eshape = NA, |
| 139 | + f = comp$f, |
| 140 | + ffix = NA, |
| 141 | + fshape = NA, |
| 142 | + integer = integer, |
| 143 | + J = J, |
| 144 | + K = K, |
| 145 | + lambda0 = lambda0, |
| 146 | + n_factor = comp$n_factor, |
| 147 | + n10 = n10, |
| 148 | + n1 = n1, |
| 149 | + opchar = comp$opchar, |
| 150 | + pmf_N = comp$pmf_N, |
| 151 | + power = power, |
| 152 | + ratio = ratio, |
| 153 | + stopping = stopping, |
| 154 | + summary = summary, |
| 155 | + type = type) |
| 156 | + class(output) <- c("multiarm_des_gs_pois", class(output)) |
| 157 | + output |
| 158 | + |
| 159 | +} |
0 commit comments