summary.gs_design: Generate a table summarizing the bounds in the group...

View source: R/summary.R

summary.gs_designR Documentation

Generate a table summarizing the bounds in the group sequential design

Description

Generate a table summarizing the bounds in the group sequential design generated by gs_design_ahr(), gs_design_wlr(), or gs_design_combo().

Usage

## S3 method for class 'gs_design'
summary(
  object,
  analysis_vars = NULL,
  analysis_decimals = NULL,
  col_vars = NULL,
  col_decimals = NULL,
  bound_names = c("Efficacy", "Futility"),
  ...
)

Arguments

object

An object returned by gs_design_ahr(), gs_design_wlr(), or gs_design_combo()

analysis_vars

The variables to be put at the summary header of each analysis

analysis_decimals

The displayed number of digits of analysis_vars

col_vars

The variables to be displayed

col_decimals

The decimals to be displayed for the displayed variables in col_vars

bound_names

Names for bounds; default is c("Efficacy", "Futility").

...

Additional arguments

Value

A summary table

Examples

# ---------------------------- #
#     design parameters        #
# ---------------------------- #
library(tibble)
library(gsDesign)
library(gsDesign2)
library(dplyr)

# enrollment/failure rates
enrollRates <- tibble(Stratum = "All",
                      duration = 12,
                      rate = 1)
failRates <- tibble(Stratum = "All", duration = c(4, 100),
                    failRate = log(2) / 12,
                    hr = c(1, .6),
                     dropoutRate = .001)

# Information fraction
IF <- (1:3)/3

# Analysis times in months; first 2 will be ignored as IF will not be achieved
analysisTimes <- c(.01, .02, 36)

# Experimental / Control randomization ratio
ratio <- 1

# 1-sided Type I error
alpha <- 0.025

# Type II error (1 - power)
beta <- .1

# Upper bound
upper <- gs_spending_bound
upar <- list(sf = gsDesign::sfLDOF, total_spend = 0.025, param = NULL, timing = NULL)

# Lower bound
lower <- gs_spending_bound
lpar <- list(sf = gsDesign::sfHSD, total_spend = 0.1, param = 0, timing = NULL)

# weight function in WLR
wgt00 <- function(x, arm0, arm1){wlr_weight_fh(x, arm0, arm1, rho = 0, gamma = 0)}
wgt05 <- function(x, arm0, arm1){wlr_weight_fh(x, arm0, arm1, rho = 0, gamma = .5)}

# test in COMBO
fh_test <- rbind(
  data.frame(rho = 0, gamma = 0, tau = -1, test = 1, Analysis = 1:3,analysisTimes = c(12, 24, 36)),
  data.frame(rho = c(0, 0.5), gamma = 0.5, tau = -1, test = 2:3, Analysis = 3, analysisTimes = 36)
)

# ---------------------------- #
#          ahr                 #
# ---------------------------- #
x_ahr <- gs_design_ahr(
  enrollRates = enrollRates,
  failRates = failRates,
  IF = IF, # Information fraction
  analysisTimes = analysisTimes,
  ratio = ratio,
  alpha = alpha,
  beta = beta,
  upper = upper,
  upar = upar,
  lower = lower,
  lpar = lpar)

x_ahr %>% summary()
x_ahr %>% summary(analysis_vars = c("Time", "Events", "IF"), analysis_decimals = c(1, 0, 2))
x_ahr %>% summary(bound_names = c("A is better", "B is better"))

# ---------------------------- #
#         wlr                  #
# ---------------------------- #
x_wlr <- gs_design_wlr(
  enrollRates = enrollRates,
  failRates = failRates,
  weight = wgt05,
  IF = NULL,
  analysisTimes = sort(unique(x_ahr$analysis$Time)),
  ratio = ratio,
  alpha = alpha,
  beta = beta,
  upper = upper,
  upar = upar,
  lower = lower,
  lpar = lpar
)
x_wlr %>% summary()

# ---------------------------- #
#         max combo            #
# ---------------------------- #
x_combo <- gs_design_combo(
  ratio = 1,
  alpha = 0.025,
  beta = 0.2,
  enrollRates = tibble::tibble(Stratum = "All", duration = 12, rate = 500/12),
  failRates = tibble::tibble(Stratum = "All", duration = c(4, 100),
                             failRate = log(2) / 15, hr = c(1, .6), dropoutRate = .001),
  fh_test = fh_test,
  upper = gs_spending_combo,
  upar = list(sf = gsDesign::sfLDOF, total_spend = 0.025),
  lower = gs_spending_combo,
  lpar = list(sf = gsDesign::sfLDOF, total_spend = 0.2))
x_combo %>% summary()

# ---------------------------- #
#      risk difference         #
# ---------------------------- #
gs_design_rd(
  p_c = tibble(Stratum = "All", Rate = .2),
  p_e = tibble(Stratum = "All", Rate = .15),
  IF = c(0.7, 1),
  rd0 = 0,
  alpha = .025,
  beta = .1,
  ratio = 1,
  stratum_prev = NULL,
  weight = "un-stratified",
  upper = gs_b,
  lower = gs_b,
  upar = gsDesign::gsDesign(k = 3, test.type = 1, sfu = gsDesign::sfLDOF, sfupar = NULL)$upper$bound,
  lpar = c(qnorm(.1), rep(-Inf, 2))
) %>% summary()


keaven/gsDesign2 documentation built on Oct. 13, 2022, 8:42 p.m.