Skip to content

Commit 0969b30

Browse files
Merge pull request #501 from Merck/500-improve-the-documentation-and-spec-of-gs_design_ahrand-gs_power_ahr
improve the documentation of `gs_design_ahr` and `gs_power_ahr`
2 parents fc3e9a6 + b8ee611 commit 0969b30

9 files changed

+250
-203
lines changed

R/gs_design_ahr.R

+38-42
Original file line numberDiff line numberDiff line change
@@ -16,28 +16,40 @@
1616
# You should have received a copy of the GNU General Public License
1717
# along with this program. If not, see <http://www.gnu.org/licenses/>.
1818

19-
#' Group sequential design using average hazard ratio under non-proportional hazards
19+
#' Calculate sample size and bounds given targeted power and Type I error in group sequential design using average hazard ratio under non-proportional hazards
2020
#'
21-
#' @param enroll_rate Enrollment rates.
22-
#' @param fail_rate Failure and dropout rates.
23-
#' @param ratio Experimental:Control randomization ratio (not yet implemented).
21+
#' @param enroll_rate Enrollment rates defined by \code{define_enroll_rate()}.
22+
#' @param fail_rate Failure and dropout rates defined by \code{define_fail_rate()}.
23+
#' @param ratio Experimental:Control randomization ratio.
2424
#' @param alpha One-sided Type I error.
2525
#' @param beta Type II error.
26-
#' @param info_frac Targeted information fraction at each analysis.
27-
#' @param analysis_time Minimum time of analysis.
26+
#' @param info_frac Targeted information fraction for analyses. See details.
27+
#' @param analysis_time Targeted calendar timing of analyses. See details.
2828
#' @param binding Indicator of whether futility bound is binding;
2929
#' default of `FALSE` is recommended.
3030
#' @param upper Function to compute upper bound.
31+
#' - \code{gs_spending_bound()}: alpha-spending efficacy bounds.
32+
#' - \code{gs_b()}: fixed efficacy bounds.
3133
#' @param upar Parameters passed to `upper`.
32-
#' @param lower Function to compute lower bound.
33-
#' @param lpar Parameters passed to `lower`.
34+
#' - If `upper = gs_b`, then `upar` is a numerical vector specifying the fixed efficacy bounds per analysis.
35+
#' - If `upper = gs_spending_bound`, then `upar` is a list including
36+
#' - `sf` for the spending function family.
37+
#' - `total_spend` for total alpha spend.
38+
#' - `param` for the parameter of the spending function.
39+
#' - `timing` specifies spending time if different from information-based spending; see details.
40+
#' @param lower Function to compute lower bound, which can be set up similarly as `upper`.
41+
#' See [this vignette](https://merck.github.io/gsDesign2/articles/story-seven-test-types.html).
42+
#' @param lpar Parameters passed to `lower`, which can be set up similarly as `upar.`
3443
#' @param info_scale Information scale for calculation. Options are:
3544
#' - `"h0_h1_info"` (default): variance under both null and alternative hypotheses is used.
3645
#' - `"h0_info"`: variance under null hypothesis is used.
3746
#' - `"h1_info"`: variance under alternative hypothesis is used.
3847
#' @param h1_spending Indicator that lower bound to be set by spending
3948
#' under alternate hypothesis (input `fail_rate`)
4049
#' if spending is used for lower bound.
50+
#' If this is `FALSE`, then the lower bound spending is under the null hypothesis.
51+
#' This is for two-sided symmetric or asymmetric testing under the null hypothesis;
52+
#' See [this vignette](https://merck.github.io/gsDesign2/articles/story-seven-test-types.html).
4153
#' @param test_upper Indicator of which analyses should include an upper
4254
#' (efficacy) bound; single value of `TRUE` (default) indicates all analyses;
4355
#' otherwise, a logical vector of the same length as `info` should indicate
@@ -51,45 +63,29 @@
5163
#' Jennison and Turnbull (2000); default is 18, range is 1 to 80.
5264
#' Larger values provide larger number of grid points and greater accuracy.
5365
#' Normally, `r` will not be changed by the user.
54-
#' @param tol Tolerance parameter for boundary convergence (on Z-scale).
55-
#' @param interval An interval that is presumed to include the time at which
66+
#' @param tol Tolerance parameter for boundary convergence (on Z-scale); normally not changed by the user.
67+
#' @param interval An interval presumed to include the times at which
5668
#' expected event count is equal to targeted event.
69+
#' Normally, this can be ignored by the user as it is set to `c(.01, 1000)`.
5770
#'
5871
#' @return A list with input parameters, enrollment rate, analysis, and bound.
59-
#'
60-
#' @section Specification:
61-
#' \if{latex}{
62-
#' \itemize{
63-
#' \item Validate if input analysis_time is a positive number or positive
64-
#' increasing sequence.
65-
#' \item Validate if input info_frac is a positive number or positive
66-
#' increasing sequence
67-
#' on (0, 1] with final value of 1.
68-
#' \item Validate if input info_frac and analysis_time have the same
69-
#' length if both have length > 1.
70-
#' \item Get information at input analysis_time
71-
#' \itemize{
72-
#' \item Use \code{gs_info_ahr()} to get the information and effect size
73-
#' based on AHR approximation.
74-
#' \item Extract the final event.
75-
#' \item Check if input If needed for (any) interim analysis timing.
76-
#' }
77-
#' \item Add the analysis column to the information at input analysis_time.
78-
#' \item Add the sample size column to the information at input analysis_time
79-
#' using \code{expected_accural()}.
80-
#' \item Get sample size and bounds using \code{gs_design_npe()} and
81-
#' save them to bounds.
82-
#' \item Add Time, Events, AHR, N that have already been calculated
83-
#' to the bounds.
84-
#' \item Return a list of design enrollment, failure rates, and bounds.
85-
#' }
86-
#' }
87-
#' \if{html}{The contents of this section are shown in PDF user manual only.}
72+
#' - The `$input` is a list including `alpha`, `beta`, `ratio`, etc.
73+
#' - The `$enroll_rate` is a table showing the enrollment for arriving the targeted power (`1 - beta`).
74+
#' - The `$fail_rate` is a table showing the failure and dropout rates, which is the same as input.
75+
#' - The `$bound` is a table summarizing the efficacy and futility bound per analysis.
76+
#' - The `analysis` is a table summarizing the analysis time, sample size, events, average HR, treatment effect and statistical information per analysis.
77+
#' @export
8878
#'
8979
#' @details
90-
#' To be added.
91-
#'
92-
#' @export
80+
#' The parameters `info_frac` and `analysis_time` are used to determine the timing for interim and final analyses.
81+
#' - If the interim analysis is determined by targeted information fraction and the study duration is known,
82+
#' then `info_frac` is a numerical vector where each element (greater than 0 and less than or equal to 1)
83+
#' represents the information fraction for each analysis.
84+
#' The `analysis_time`, which defaults to 36, indicates the time for the final analysis.
85+
#' - If interim analyses are determined solely by the targeted calendar analysis timing from start of study,
86+
#' then `analysis_time` will be a vector specifying the time for each analysis.
87+
#' - If both the targeted analysis time and the targeted information fraction are utilized for a given analysis,
88+
#' then timing will be the maximum of the two with both `info_frac` and `analysis_time` provided as vectors.
9389
#'
9490
#' @examples
9591
#' library(gsDesign)

R/gs_power_ahr.R

+31-50
Original file line numberDiff line numberDiff line change
@@ -19,66 +19,40 @@
1919
#' Group sequential design power using average hazard ratio under
2020
#' non-proportional hazards
2121
#'
22-
#' Group sequential design power using average hazard ratio under
22+
#' Calculate power given the sample size in group sequential design power using average hazard ratio under
2323
#' non-proportional hazards.
2424
#'
25-
#' @inheritParams ahr
26-
#' @param fail_rate Failure and dropout rates.
27-
#' @param ratio Experimental:Control randomization ratio (not yet implemented).
28-
#' @param event Targeted event at each analysis.
29-
#' @param analysis_time Minimum time of analysis.
30-
#' @param binding Indicator of whether futility bound is binding;
31-
#' default of `FALSE` is recommended.
32-
#' @param info_scale Information scale for calculation. Options are:
33-
#' - `"h0_h1_info"` (default): variance under both null and alternative hypotheses is used.
34-
#' - `"h0_info"`: variance under null hypothesis is used.
35-
#' - `"h1_info"`: variance under alternative hypothesis is used.
36-
#' @param upper Function to compute upper bound.
37-
#' @param upar Parameters passed to `upper`.
38-
#' @param lower Function to compute lower bound.
39-
#' @param lpar Parameters passed to `lower`.
40-
#' @param test_upper Indicator of which analyses should include an upper
41-
#' (efficacy) bound; single value of `TRUE` (default) indicates all analyses;
42-
#' otherwise, a logical vector of the same length as `info` should
43-
#' indicate which analyses will have an efficacy bound.
44-
#' @param test_lower Indicator of which analyses should include an lower bound;
45-
#' single value of `TRUE` (default) indicates all analyses;
46-
#' single value of `FALSE` indicated no lower bound;
47-
#' otherwise, a logical vector of the same length as `info` should indicate
48-
#' which analyses will have a lower bound.
49-
#' @param r Integer value controlling grid for numerical integration as in
50-
#' Jennison and Turnbull (2000); default is 18, range is 1 to 80.
51-
#' Larger values provide larger number of grid points and greater accuracy.
52-
#' Normally, `r` will not be changed by the user.
53-
#' @param tol Tolerance parameter for boundary convergence (on Z-scale).
54-
#' @param interval An interval that is presumed to include the time at which
55-
#' expected event count is equal to targeted event.
56-
#' @param integer Logical value integer whether it is an integer design
57-
#' (i.e., integer sample size and events) or not. This argument is commonly
58-
#' used when creating integer design via [to_integer()].
25+
#' @inheritParams gs_design_ahr
26+
#' @param event A numerical vector specifying the targeted events at each analysis. See details.
27+
#' @param integer Indicator of whether integer sample size and events are intended. This argument is
28+
#' used when using [to_integer()].
5929
#'
60-
#' @return A tibble with columns `analysis`, `bound`, `z`, `probability`,
61-
#' `theta`, `time`, `ahr`, `event`.
62-
#' Contains a row for each analysis and each bound.
30+
#' @return A list with input parameters, enrollment rate, analysis, and bound.
31+
#' - `$input` a list including `alpha`, `beta`, `ratio`, etc.
32+
#' - `$enroll_rate` a table showing the enrollment, which is the same as input.
33+
#' - `$fail_rate` a table showing the failure and dropout rates, which is the same as input.
34+
#' - `$bound` a table summarizing the efficacy and futility bound at each analysis.
35+
#' - `analysis` a table summarizing the analysis time, sample size, events, average HR, treatment effect and statistical information at each analysis.
6336
#'
6437
#' @details
65-
#' Bound satisfy input upper bound specification in
38+
#' Note that time units are arbitrary, but should be the same for all rate parameters in `enroll_rate`, `fail_rate`, and `analysis_time`.
39+
#'
40+
#' Computed bounds satisfy input upper bound specification in
6641
#' `upper`, `upar`, and lower bound specification in `lower`, `lpar`.
6742
#' [ahr()] computes statistical information at targeted event times.
6843
#' The [expected_time()] function is used to get events and average HR at
6944
#' targeted `analysis_time`.
7045
#'
71-
#' @section Specification:
72-
#' \if{latex}{
73-
#' \itemize{
74-
#' \item Calculate information and effect size based on AHR approximation
75-
#' using \code{gs_info_ahr()}.
76-
#' \item Return a tibble of with columns Analysis, Bound, Z, Probability,
77-
#' theta, Time, AHR, Events and contains a row for each analysis
78-
#' and each bound.
79-
#' }
80-
#' }
81-
#' \if{html}{The contents of this section are shown in PDF user manual only.}
46+
#' The parameters `event` and `analysis_time` are used to determine the timing for interim and final analyses.
47+
#' - If analysis timing is to be determined by targeted events,
48+
#' then `event` is a numerical vector specifying the targeted events for each analysis;
49+
#' note that this can be NULL.
50+
#' - If interim analysis is determined by targeted calendar timing relative to start of enrollment,
51+
#' then `analysis_time` will be a vector specifying the calendar time from start of study for each analysis;
52+
#' note that this can be NULL.
53+
#' - A corresponding element of `event` or `analysis_time` should be provided for each analysis.
54+
#' - If both `event[i]` and `analysis[i]` are provided for analysis `i`, then the time corresponding to the
55+
#' later of these is used for analysis `i`.
8256
#'
8357
#' @export
8458
#'
@@ -109,6 +83,13 @@
10983
#' # Example 3 ----
11084
#' # 2-sided symmetric O'Brien-Fleming spending bound, driven by event,
11185
#' # i.e., `event = c(20, 50, 70)`, `analysis_time = NULL`
86+
#' # Note that this assumes targeted final events for the design is 70 events.
87+
#' # If actual targeted final events were 65, then `timing = c(20, 50, 70) / 65`
88+
#' # would be added to `upar` and `lpar` lists.
89+
#' # NOTE: at present the computed information fraction in output `analysis` is based
90+
#' # on 70 events rather than 65 events when the `timing` argument is used in this way.
91+
#` # This behavior is likely to be updated in the near future.
92+
#' # A vignette on this topic will be forthcoming.
11293
#' \donttest{
11394
#' gs_power_ahr(
11495
#' analysis_time = NULL,

man/fixed_design.Rd

+3-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/gs_design_ahr.Rd

+42-42
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)