Skip to content

Commit

Permalink
Finetune fixed_design documentation format
Browse files Browse the repository at this point in the history
  • Loading branch information
nanxstats committed Feb 22, 2024
1 parent 1c9a01b commit eea069f
Show file tree
Hide file tree
Showing 9 changed files with 95 additions and 75 deletions.
36 changes: 21 additions & 15 deletions R/fixed_design_ahr.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,22 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

#' Fixed design under non-proportional hazards.
#' Fixed design under non-proportional hazards
#'
#' @description
#' Computes fixed design sample size (given power)
#' or power (given sample size) by either AHR method
#' \code{fixed_design_ahr}, weighted logrank test with
#' Fleming-Harrington weights (Farrington and Manning, 1990)
#' \code{fixed_design_fh}, weighted logrank test with
#' Magirr-Burman weights \code{fixed_design_mb},
#' Lachin-Foulkes method (Lachin and Foulkes, 1986)
#' \code{fixed_design_lf}, MaxCombo method \code{fixed_design_combo},
#' RMST method \code{fixed_design_rmst}, or milestone method
#' \code{fixed_design_milestone}. Additionally, we provide the fixed
#' design for binary endpoint with treatment effect measuring in
#' risk difference \code{fixed_design_rd}.
#' or power (given sample size) by:
#' - [fixed_design_ahr()] - Average hazard ratio method.
#' - [fixed_design_fh()] - Weighted logrank test with Fleming-Harrington
#' weights (Farrington and Manning, 1990).
#' - [fixed_design_mb()] - Weighted logrank test with Magirr-Burman weights.
#' - [fixed_design_lf()] - Lachin-Foulkes method (Lachin and Foulkes, 1986).
#' - [fixed_design_combo()] - MaxCombo method.
#' - [fixed_design_rmst()] - RMST method.
#' - [fixed_design_milestone()] - Milestone method.
#'
#' Additionally, [fixed_design_rd()] provides fixed design for binary endpoint
#' with treatment effect measuring in risk difference.
#'
#' @inheritParams gs_design_ahr
#' @inheritParams gs_power_ahr
Expand All @@ -38,13 +40,18 @@
#' @param study_duration Study duration.
#'
#' @importFrom dplyr filter
#'
#' @returns A list of design characteristic summary.
#'
#' @export
#'
#' @rdname fixed_design
#'
#' @examples
#' # AHR method ----
#' library(dplyr)
#'
#' # AHR method example 1: given power and compute sample size
#' # Example 1: given power and compute sample size
#' x <- fixed_design_ahr(
#' alpha = .025, power = .9,
#' enroll_rate = define_enroll_rate(duration = 18, rate = 1),
Expand All @@ -58,7 +65,7 @@
#' )
#' x %>% summary()
#'
#' # AHR method example 2: given sample size and compute power
#' # Example 2: given sample size and compute power
#' x <- fixed_design_ahr(
#' alpha = .025,
#' enroll_rate = define_enroll_rate(duration = 18, rate = 20),
Expand All @@ -72,7 +79,6 @@
#' )
#' x %>% summary()
#'
#' # ---
fixed_design_ahr <- function(
enroll_rate,
fail_rate,
Expand Down
9 changes: 5 additions & 4 deletions R/fixed_design_fh.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.


#' @inheritParams gs_design_wlr
#' @inheritParams gs_power_wlr
#' @param power Power (`NULL` to compute power or strictly between 0
Expand All @@ -28,11 +27,14 @@
#' @importFrom dplyr filter
#'
#' @export
#'
#' @rdname fixed_design
#'
#' @examples
#' # WLR test with FH weights ----
#' library(dplyr)
#'
#' # WLR test with FH weights example 1: given power and compute sample size
#' # Example 1: given power and compute sample size
#' x <- fixed_design_fh(
#' alpha = .025, power = .9,
#' enroll_rate = define_enroll_rate(duration = 18, rate = 1),
Expand All @@ -47,7 +49,7 @@
#' )
#' x %>% summary()
#'
#' # WLR test with FH weights example 2: given sample size and compute power
#' # Example 2: given sample size and compute power
#' x <- fixed_design_fh(
#' alpha = .025,
#' enroll_rate = define_enroll_rate(duration = 18, rate = 20),
Expand All @@ -62,7 +64,6 @@
#' )
#' x %>% summary()
#'
#' # ----
fixed_design_fh <- function(
alpha = 0.025,
power = NULL,
Expand Down
8 changes: 5 additions & 3 deletions R/fixed_design_lf.R
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,14 @@
#' @inheritParams gs_design_ahr
#'
#' @export
#'
#' @rdname fixed_design
#'
#' @examples
#' # LF method ----
#' library(dplyr)
#'
#' # LF method example 1: given power and compute sample size
#' # Example 1: given power and compute sample size
#' x <- fixed_design_lf(
#' alpha = .025, power = .9,
#' enroll_rate = define_enroll_rate(duration = 18, rate = 1),
Expand All @@ -42,7 +45,7 @@
#' )
#' x %>% summary()
#'
#' # LF method example 2: given sample size and compute power
#' # Example 2: given sample size and compute power
#' x <- fixed_design_fh(
#' alpha = .025,
#' enroll_rate = define_enroll_rate(duration = 18, rate = 20),
Expand All @@ -56,7 +59,6 @@
#' )
#' x %>% summary()
#'
#' # ----
fixed_design_lf <- function(
alpha = 0.025,
power = NULL,
Expand Down
8 changes: 5 additions & 3 deletions R/fixed_design_maxcombo.R
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,14 @@
#' @inheritParams gs_design_combo
#'
#' @export
#'
#' @rdname fixed_design
#'
#' @examples
#' # MaxCombo test ----
#' library(dplyr)
#'
#' # Maxcombo test example 1: given power and compute sample size
#' # Example 1: given power and compute sample size
#' x <- fixed_design_maxcombo(
#' alpha = .025, power = .9,
#' enroll_rate = define_enroll_rate(duration = 18, rate = 1),
Expand All @@ -46,7 +49,7 @@
#' )
#' x %>% summary()
#'
#' # Maxcombo test example 2: given sample size and compute power
#' # Example 2: given sample size and compute power
#' x <- fixed_design_maxcombo(
#' alpha = .025,
#' enroll_rate = define_enroll_rate(duration = 18, rate = 20),
Expand All @@ -61,7 +64,6 @@
#' )
#' x %>% summary()
#'
#' # ----
fixed_design_maxcombo <- function(
alpha = 0.025,
power = NULL,
Expand Down
8 changes: 5 additions & 3 deletions R/fixed_design_mb.R
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,14 @@
#' @param tau Test parameter of Magirr-Burman method.
#'
#' @export
#'
#' @rdname fixed_design
#'
#' @examples
#' # WLR test with MB weights ----
#' library(dplyr)
#'
#' # WLR test with MB weights example 1: given power and compute sample size
#' # Example 1: given power and compute sample size
#' x <- fixed_design_mb(
#' alpha = .025, power = .9,
#' enroll_rate = define_enroll_rate(duration = 18, rate = 1),
Expand All @@ -44,7 +47,7 @@
#' )
#' x %>% summary()
#'
#' # WLR test with MB weights example 2: given sample size and compute power
#' # Example 2: given sample size and compute power
#' x <- fixed_design_mb(
#' alpha = .025,
#' enroll_rate = define_enroll_rate(duration = 18, rate = 20),
Expand All @@ -59,7 +62,6 @@
#' )
#' x %>% summary()
#'
#' # ----
fixed_design_mb <- function(
alpha = 0.025,
power = NULL,
Expand Down
8 changes: 5 additions & 3 deletions R/fixed_design_milestone.R
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,14 @@
#' @param tau Test parameter of milestone method.
#'
#' @export
#'
#' @rdname fixed_design
#'
#' @examples
#' # Milestone method ----
#' library(dplyr)
#'
#' # Milestone method example 1: given power and compute sample size
#' # Example 1: given power and compute sample size
#' x <- fixed_design_milestone(
#' alpha = .025, power = .9,
#' enroll_rate = define_enroll_rate(duration = 18, rate = 1),
Expand All @@ -44,7 +47,7 @@
#' )
#' x %>% summary()
#'
#' # Milestone method example 2: given sample size and compute power
#' # Example 2: given sample size and compute power
#' x <- fixed_design_milestone(
#' alpha = .025,
#' enroll_rate = define_enroll_rate(duration = 18, rate = 20),
Expand All @@ -59,7 +62,6 @@
#' )
#' x %>% summary()
#'
#' # ----
fixed_design_milestone <- function(
alpha = 0.025,
power = NULL,
Expand Down
8 changes: 5 additions & 3 deletions R/fixed_design_rd.R
Original file line number Diff line number Diff line change
Expand Up @@ -27,25 +27,27 @@
#' @param ratio Experimental:Control randomization ratio.
#'
#' @export
#'
#' @rdname fixed_design
#'
#' @examples
#' # Binary endpoint with risk differences ----
#' library(dplyr)
#'
#' # Binary endpoint with risk differences example 1: given power and compute sample size
#' # Example 1: given power and compute sample size
#' x <- fixed_design_rd(
#' alpha = 0.025, power = 0.9, p_c = .15, p_e = .1,
#' rd0 = 0, ratio = 1
#' )
#' x %>% summary()
#'
#' # Binary endpoint with risk differences example 2: given sample size and compute power
#' # Example 2: given sample size and compute power
#' x <- fixed_design_rd(
#' alpha = 0.025, power = NULL, p_c = .15, p_e = .1,
#' rd0 = 0, n = 2000, ratio = 1
#' )
#' x %>% summary()
#'
#' # ----
fixed_design_rd <- function(
alpha = 0.025,
power = NULL,
Expand Down
9 changes: 5 additions & 4 deletions R/fixed_design_rmst.R
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,14 @@
#' @param tau Test parameter in RMST.
#'
#' @export
#'
#' @rdname fixed_design
#'
#' @examples
#' # RMST method ----
#' library(dplyr)
#'
#' # RMST method example 1: given power and compute sample size
#' # Example 1: given power and compute sample size
#' x <- fixed_design_rmst(
#' alpha = .025, power = .9,
#' enroll_rate = define_enroll_rate(duration = 18, rate = 1),
Expand All @@ -44,7 +47,7 @@
#' )
#' x %>% summary()
#'
#' # RMST method example 2: given sample size and compute power
#' # Example 2: given sample size and compute power
#' x <- fixed_design_rmst(
#' alpha = .025,
#' enroll_rate = define_enroll_rate(duration = 18, rate = 20),
Expand All @@ -58,8 +61,6 @@
#' tau = 18
#' )
#' x %>% summary()
#'
#' # ----
fixed_design_rmst <- function(
alpha = 0.025,
power = NULL,
Expand Down
Loading

0 comments on commit eea069f

Please sign in to comment.