|
16 | 16 | # You should have received a copy of the GNU General Public License |
17 | 17 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
18 | 18 |
|
19 | | -#' Group sequential bound computation with non-constant effect |
| 19 | +#' @title Group sequential design computation with non-constant effect and information. |
20 | 20 | #' |
21 | | -#' Derives group sequential bounds and boundary crossing probabilities for a design. |
22 | | -#' It allows a non-constant treatment effect over time, |
| 21 | +#' @description The following two functions allow a non-constant treatment effect over time, |
23 | 22 | #' but also can be applied for the usual homogeneous effect size designs. |
24 | | -#' It requires treatment effect and statistical information at each analysis |
| 23 | +#' They require treatment effect and statistical information at each analysis |
25 | 24 | #' as well as a method of deriving bounds, such as spending. |
26 | | -#' The routine enables two things not available in the gsDesign package: |
27 | | -#' 1) non-constant effect, 2) more flexibility in boundary selection. |
28 | | -#' For many applications, the non-proportional-hazards design function |
29 | | -#' `gs_design_nph()` will be used; it calls this function. |
30 | | -#' Initial bound types supported are 1) spending bounds, |
31 | | -#' 2) fixed bounds, and 3) Haybittle-Peto-like bounds. |
32 | | -#' The requirement is to have a boundary update method that can |
33 | | -#' each bound without knowledge of future bounds. |
34 | | -#' As an example, bounds based on conditional power that require |
35 | | -#' knowledge of all future bounds are not supported by this routine; |
36 | | -#' a more limited conditional power method will be demonstrated. |
37 | | -#' Boundary family designs Wang-Tsiatis designs including the |
38 | | -#' original (non-spending-function-based) O'Brien-Fleming and Pocock designs |
39 | | -#' are not supported by `gs_power_npe()`. |
| 25 | +#' Initial bound types supported are spending bounds and fixed bounds. |
| 26 | +#' These routines enables two things not available in the gsDesign package: 1) |
| 27 | +#' non-constant effect, 2) more flexibility in boundary selection. |
| 28 | +#' |
| 29 | +#' \code{gs_power_npe()} derives group sequential bounds and boundary crossing probabilities |
| 30 | +#' for a design, given treatment effect and information at each analysis and the |
| 31 | +#' method of deriving bounds, such as spending. |
| 32 | +#' |
| 33 | +#' \code{gs_design_npe()} derives group sequential design size, |
| 34 | +#' bounds and boundary crossing probabilities based on proportionate |
| 35 | +#' information and effect size at analyses, as well as the |
| 36 | +#' method of deriving bounds, such as spending. |
| 37 | +#' |
| 38 | +#' The only differences in arguments between the two functions are the \code{alpha} and \code{beta} |
| 39 | +#' parameters used in the \code{gs_design_npe()}. |
40 | 40 | #' |
41 | 41 | #' @param theta Natural parameter for group sequential design representing |
42 | | -#' expected incremental drift at all analyses; used for power calculation. |
43 | | -#' @param theta0 Natural parameter for null hypothesis, |
44 | | -#' if needed for upper bound computation. |
| 42 | +#' expected cumulative drift at all analyses; used for power calculation. |
| 43 | +#' It can be a scalar (constant treatment effect) or a vector (non-constant treatment effect). |
| 44 | +#' The user must provide a value for `theta`. |
| 45 | +#' @param theta0 Natural parameter for null hypothesis. |
| 46 | +#' It can be a scalar (constant treatment effect) or a vector (non-constant treatment effect). |
| 47 | +#' The default is 0. If a value other than 0 is provided, it affects upper bound computation. |
45 | 48 | #' @param theta1 Natural parameter for alternate hypothesis, |
46 | 49 | #' if needed for lower bound computation. |
| 50 | +#' It can be a scalar (constant treatment effect) or a vector (non-constant treatment effect). |
| 51 | +#' The default is the same as `theta`, which yields the usual beta-spending. |
| 52 | +#' If set to 0, spending is 2-sided under the null hypothesis. |
47 | 53 | #' @param info Statistical information at all analyses for input `theta`. |
48 | | -#' @param info0 Statistical information under null hypothesis, |
49 | | -#' if different than `info`; |
50 | | -#' impacts null hypothesis bound calculation. |
51 | | -#' @param info1 Statistical information under hypothesis used for |
52 | | -#' futility bound calculation if different from |
53 | | -#' `info`; impacts futility hypothesis bound calculation. |
| 54 | +#' It is a vector of positive numbers in increasing order. |
| 55 | +#' The user must provide values corresponding to `theta`. |
| 56 | +#' @param info0 Statistical information under null hypothesis. |
| 57 | +#' It is a vector of all positive numbers with increasing order. |
| 58 | +#' Default is set to be the same as `info`. |
| 59 | +#' If `info0` is different than `info`, it impacts null hypothesis bound calculation. |
| 60 | +#' @param info1 Statistical information under hypothesis used for futility bound calculation. |
| 61 | +#' It is a vector of all positive numbers with increasing order. |
| 62 | +#' Default is set to be the same as `info`. |
| 63 | +#' If `info1` is different from `info`, it impacts futility bound calculation. |
54 | 64 | #' @param info_scale Information scale for calculation. Options are: |
55 | 65 | #' - `"h0_h1_info"` (default): variance under both null and alternative hypotheses is used. |
56 | 66 | #' - `"h0_info"`: variance under null hypothesis is used. |
| 67 | +#' This is often used for testing methods that use local alternatives, such as the Schoenfeld method. |
57 | 68 | #' - `"h1_info"`: variance under alternative hypothesis is used. |
58 | 69 | #' @param binding Indicator of whether futility bound is binding; |
59 | 70 | #' default of `FALSE` is recommended. |
|
77 | 88 | #' Normally, `r` will not be changed by the user. |
78 | 89 | #' @param tol Tolerance parameter for boundary convergence (on Z-scale). |
79 | 90 | #' |
80 | | -#' @return A tibble with columns as analysis index, bounds, z, |
81 | | -#' crossing probability, theta (standardized treatment effect), |
82 | | -#' theta1 (standardized treatment effect under alternative hypothesis), |
83 | | -#' information fraction, and statistical information. |
| 91 | +#' @return A tibble with columns of |
| 92 | +#' - `analysis`: analysis index. |
| 93 | +#' - `bound`: either of value `"upper"` or `"lower"`, indicating the upper and lower bound. |
| 94 | +#' - `z`: the Z-score bounds. |
| 95 | +#' - `probability`: cumulative probability of crossing the bound at or before the analysis. |
| 96 | +#' - `theta`: same as the input. |
| 97 | +#' - `theta1`: same as the input. |
| 98 | +#' - `info`: statistical information at each analysis. |
| 99 | +#' + If it is returned by `gs_power_npe`, the `info`, `info0`, `info1` are same as the input. |
| 100 | +#' + If it is returned by `gs_design_npe`, the `info`, `info0`, `info1` are changed by a constant scale factor. |
| 101 | +#' factor to ensure the design has power `1 - beta`. |
| 102 | +#' - `info0`: statistical information under the null at each analysis. |
| 103 | +#' - `info1`: statistical information under the alternative at each analysis. |
| 104 | +#' - `info_frac`: information fraction at each analysis, i.e., `info / max(info)`. |
84 | 105 | #' |
85 | 106 | #' @section Specification: |
86 | 107 | #' \if{latex}{ |
|
117 | 138 | #' } |
118 | 139 | #' \if{html}{The contents of this section are shown in PDF user manual only.} |
119 | 140 | #' |
| 141 | +#' @name gs_power_design_npe |
| 142 | +#' @rdname gs_power_design_npe |
120 | 143 | #' @export |
121 | 144 | #' |
122 | 145 | #' @examples |
123 | | -#' library(dplyr) |
124 | | -#' library(gsDesign) |
125 | | -#' library(gsDesign2) |
126 | 146 | #' |
127 | | -#' # Default (single analysis; Type I error controlled) |
128 | | -#' gs_power_npe(theta = 0) |> filter(bound == "upper") |
| 147 | +#' # Example 6 ---- |
| 148 | +#' # Default of gs_power_npe (single analysis; Type I error controlled) |
| 149 | +#' gs_power_npe(theta = 0) |> dplyr::filter(bound == "upper") |
129 | 150 | #' |
130 | | -#' # Fixed bound |
| 151 | +#' # Example 7 ---- |
| 152 | +#' # gs_power_npe with fixed bound |
131 | 153 | #' gs_power_npe( |
132 | 154 | #' theta = c(.1, .2, .3), |
133 | 155 | #' info = (1:3) * 40, |
|
144 | 166 | #' upar = gsDesign::gsDesign(k = 3, sfu = gsDesign::sfLDOF)$upper$bound, |
145 | 167 | #' lpar = rep(-Inf, 3) |
146 | 168 | #' ) |> |
147 | | -#' filter(bound == "upper") |
| 169 | +#' dplyr::filter(bound == "upper") |
148 | 170 | #' |
149 | | -#' # Fixed bound with futility only at analysis 1; efficacy only at analyses 2, 3 |
| 171 | +#' # Example 8 ---- |
| 172 | +#' # gs_power_npe with fixed bound testing futility only at analysis 1; efficacy only at analyses 2, 3 |
150 | 173 | #' gs_power_npe( |
151 | 174 | #' theta = c(.1, .2, .3), |
152 | 175 | #' info = (1:3) * 40, |
|
156 | 179 | #' lpar = c(qnorm(.1), -Inf, -Inf) |
157 | 180 | #' ) |
158 | 181 | #' |
159 | | -#' # Spending function bounds |
| 182 | +#' # Example 9 ---- |
| 183 | +#' # gs_power_npe with spending function bounds |
160 | 184 | #' # Lower spending based on non-zero effect |
161 | 185 | #' gs_power_npe( |
162 | 186 | #' theta = c(.1, .2, .3), |
|
177 | 201 | #' lpar = list(sf = gsDesign::sfHSD, total_spend = 0.1, param = -1, timing = NULL) |
178 | 202 | #' ) |
179 | 203 | #' |
180 | | -#' # Two-sided symmetric spend, O'Brien-Fleming spending |
| 204 | +#' # Example 10 ---- |
| 205 | +#' # gs_power_npe with two-sided symmetric spend, O'Brien-Fleming spending |
181 | 206 | #' # Typically, 2-sided bounds are binding |
182 | 207 | #' x <- gs_power_npe( |
183 | 208 | #' theta = rep(0, 3), |
|
195 | 220 | #' theta = c(.1, .2, .3), |
196 | 221 | #' info = (1:3) * 40, |
197 | 222 | #' binding = TRUE, |
198 | | -#' upar = (x |> filter(bound == "upper"))$z, |
199 | | -#' lpar = -(x |> filter(bound == "upper"))$z |
| 223 | +#' upar = (x |> dplyr::filter(bound == "upper"))$z, |
| 224 | +#' lpar = -(x |> dplyr::filter(bound == "upper"))$z |
200 | 225 | #' ) |
201 | 226 | #' |
| 227 | +#' # Example 11 ---- |
202 | 228 | #' # Different values of `r` and `tol` lead to different numerical accuracy |
203 | 229 | #' # Larger `r` and smaller `tol` give better accuracy, but leads to slow computation |
204 | 230 | #' n_analysis <- 5 |
|
0 commit comments