Skip to contents

Convert summary table of a fixed or group sequential design object to a gt object

Usage

as_gt(x, ...)

# S3 method for class 'fixed_design'
as_gt(x, title = NULL, footnote = NULL, ...)

# S3 method for class 'gs_design'
as_gt(
  x,
  title = NULL,
  subtitle = NULL,
  colname_spanner = "Cumulative boundary crossing probability",
  colname_spannersub = c("Alternate hypothesis", "Null hypothesis"),
  footnote = NULL,
  display_bound = c("Efficacy", "Futility"),
  display_columns = NULL,
  display_inf_bound = FALSE,
  ...
)

Arguments

x

A summary object of a fixed or group sequential design.

...

Additional arguments (not used).

title

A string to specify the title of the gt table.

footnote

A list containing content, location, and attr. content is a vector of string to specify the footnote text; location is a vector of string to specify the locations to put the superscript of the footnote index; attr is a vector of string to specify the attributes of the footnotes, for example, c("colname", "title", "subtitle", "analysis", "spanner"); users can use the functions in the gt package to customize the table. To disable footnotes, use footnote = FALSE.

subtitle

A string to specify the subtitle of the gt table.

colname_spanner

A string to specify the spanner of the gt table.

colname_spannersub

A vector of strings to specify the spanner details of the gt table.

display_bound

A vector of strings specifying the label of the bounds. The default is c("Efficacy", "Futility").

display_columns

A vector of strings specifying the variables to be displayed in the summary table.

display_inf_bound

Logical, whether to display the +/-inf bound.

Value

A gt_tbl object.

Examples

# Fixed design examples ----

library(dplyr)
#> 
#> Attaching package: ‘dplyr’
#> The following objects are masked from ‘package:stats’:
#> 
#>     filter, lag
#> The following objects are masked from ‘package:base’:
#> 
#>     intersect, setdiff, setequal, union

# Enrollment rate
enroll_rate <- define_enroll_rate(
  duration = 18,
  rate = 20
)

# Failure rates
fail_rate <- define_fail_rate(
  duration = c(4, 100),
  fail_rate = log(2) / 12,
  dropout_rate = .001,
  hr = c(1, .6)
)

# Study duration in months
study_duration <- 36

# Experimental / Control randomization ratio
ratio <- 1

# 1-sided Type I error
alpha <- 0.025

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

# Example 1 ----
fixed_design_ahr(
  alpha = alpha, power = 1 - beta,
  enroll_rate = enroll_rate, fail_rate = fail_rate,
  study_duration = study_duration, ratio = ratio
) %>%
  summary() %>%
  as_gt()
Fixed Design under AHR Method1
Design N Events Time Bound alpha Power
Average hazard ratio 463.078 324.7077 36 1.959964 0.025 0.9
1 Power computed with average hazard ratio method.
# Example 2 ---- fixed_design_fh( alpha = alpha, power = 1 - beta, enroll_rate = enroll_rate, fail_rate = fail_rate, study_duration = study_duration, ratio = ratio ) %>% summary() %>% as_gt()
Fixed Design under Fleming-Harrington Method1
Design N Events Time Bound alpha Power
Fleming-Harrington FH(0, 0) (logrank) 458.3509 321.3931 36 1.959964 0.025 0.9
1 Power for Fleming-Harrington test FH(0, 0) (logrank) using method of Yung and Liu.
# \donttest{ # Group sequential design examples --- library(dplyr) # Example 1 ---- # The default output gs_design_ahr() %>% summary() %>% as_gt()
Bound summary for AHR design
AHR approximations of ~HR at bound
Bound Z Nominal p1 ~HR at bound2
Cumulative boundary crossing probability
Alternate hypothesis Null hypothesis
Analysis: 1 Time: 36 N: 476 Events: 291.9 AHR: 0.68 Information fraction: 1
Efficacy 1.96 0.025 0.795 0.9 0.025
1 One-sided p-value for experimental vs control treatment. Value < 0.5 favors experimental, > 0.5 favors control.
2 Approximate hazard ratio to cross bound.
gs_power_ahr(lpar = list(sf = gsDesign::sfLDOF, total_spend = 0.1)) %>% summary() %>% as_gt()
Bound summary for AHR design
AHR approximations of ~HR at bound
Bound Z Nominal p1 ~HR at bound2
Cumulative boundary crossing probability
Alternate hypothesis Null hypothesis
Analysis: 1 Time: 14.9 N: 108 Events: 30 AHR: 0.79 Information fraction: 0.6
Futility -1.17 0.8792 1.5392 0.0349 0.1208
Efficacy 2.67 0.0038 0.3743 0.0231 0.0038
Analysis: 2 Time: 19.2 N: 108 Events: 40 AHR: 0.74 Information fraction: 0.8
Futility -0.66 0.7462 1.2359 0.0668 0.2655
Efficacy 2.29 0.0110 0.4812 0.0897 0.0122
Analysis: 3 Time: 24.5 N: 108 Events: 50 AHR: 0.71 Information fraction: 1
Futility -0.23 0.5897 1.0670 0.1008 0.4303
Efficacy 2.03 0.0211 0.5595 0.2070 0.0250
1 One-sided p-value for experimental vs control treatment. Value < 0.5 favors experimental, > 0.5 favors control.
2 Approximate hazard ratio to cross bound.
gs_design_wlr() %>% summary() %>% as_gt()
Bound summary for WLR design
WLR approximation of ~wHR at bound
Bound Z Nominal p1 ~wHR at bound2
Cumulative boundary crossing probability
Alternate hypothesis Null hypothesis
Analysis: 1 Time: 36 N: 471.1 Events: 289 AHR: 0.68 Information fraction: 13
Efficacy 1.96 0.025 0.7941 0.9 0.025
1 One-sided p-value for experimental vs control treatment. Value < 0.5 favors experimental, > 0.5 favors control.
2 Approximate hazard ratio to cross bound.
3 wAHR is the weighted AHR.
gs_power_wlr(lpar = list(sf = gsDesign::sfLDOF, total_spend = 0.1)) %>% summary() %>% as_gt()
Bound summary for WLR design
WLR approximation of ~wHR at bound
Bound Z Nominal p1 ~wHR at bound2
Cumulative boundary crossing probability
Alternate hypothesis Null hypothesis
Analysis: 1 Time: 14.9 N: 108 Events: 30 AHR: 0.79 Information fraction: 0.63
Futility -1.17 0.8798 1.5353 0.0341 0.1202
Efficacy 2.68 0.0037 0.3765 0.0217 0.0037
Analysis: 2 Time: 19.2 N: 108 Events: 40 AHR: 0.75 Information fraction: 0.83
Futility -0.66 0.7452 1.2319 0.0664 0.2664
Efficacy 2.29 0.0110 0.4846 0.0886 0.0121
Analysis: 3 Time: 24.5 N: 108 Events: 50 AHR: 0.71 Information fraction: 13
Futility -0.22 0.5881 1.0650 0.1002 0.4319
Efficacy 2.03 0.0212 0.5631 0.2071 0.0250
1 One-sided p-value for experimental vs control treatment. Value < 0.5 favors experimental, > 0.5 favors control.
2 Approximate hazard ratio to cross bound.
3 wAHR is the weighted AHR.
gs_power_combo() %>% summary() %>% as_gt()
Bound summary for MaxCombo design
MaxCombo approximation
Bound Z Nominal p1
Cumulative boundary crossing probability
Alternate hypothesis Null hypothesis
Analysis: 1 Time: 12 N: 500 Events: 107.4 AHR: 0.84 Event fraction: 0.322
Futility -1 0.8413 0.0293 0.0000
Efficacy 3 0.0013 0.0175 0.0013
Analysis: 2 Time: 24 N: 500 Events: 246.3 AHR: 0.72 Event fraction: 0.742
Futility 0 0.5000 0.0314 0.0000
Efficacy 2 0.0228 0.7261 0.0233
Analysis: 3 Time: 36 N: 500 Events: 331.3 AHR: 0.68 Event fraction: 12
Futility 1 0.1587 0.0326 0.0000
Efficacy 1 0.1587 0.9674 0.1956
1 One-sided p-value for experimental vs control treatment. Value < 0.5 favors experimental, > 0.5 favors control.
2 EF is event fraction. AHR is under regular weighted log rank test.
gs_design_rd() %>% summary() %>% as_gt()
Bound summary of Binary Endpoint
measured by risk difference
Bound Z Nominal p1 ~Risk difference at bound
Cumulative boundary crossing probability
Alternate hypothesis Null hypothesis
Analysis: 1 N: 2423.1 Risk difference: 0.05 Information fraction: 1
Efficacy 1.96 0.025 0.0302 0.9 0.025
1 One-sided p-value for experimental vs control treatment. Value < 0.5 favors experimental, > 0.5 favors control.
gs_power_rd() %>% summary() %>% as_gt()
Bound summary of Binary Endpoint
measured by risk difference
Bound Z Nominal p1 ~Risk difference at bound
Cumulative boundary crossing probability
Alternate hypothesis Null hypothesis
Analysis: 1 N: 40 Risk difference: 0.05 Information fraction: 0.67
Futility -1.28 0.9000 -0.1537 0.0444 0.1000
Efficacy 3.71 0.0001 0.4448 0.0005 0.0001
Analysis: 2 N: 50 Risk difference: 0.05 Information fraction: 0.83
Efficacy 2.51 0.0060 0.2693 0.0204 0.0060
Analysis: 3 N: 60 Risk difference: 0.05 Information fraction: 1
Efficacy 1.99 0.0231 0.1951 0.0705 2 0.0238
1 One-sided p-value for experimental vs control treatment. Value < 0.5 favors experimental, > 0.5 favors control.
2 Cumulative alpha for final analysis (0.0238) is less than the full alpha (0.025) when the futility bound is non-binding. The smaller value subtracts the probability of crossing a futility bound before crossing an efficacy bound at a later analysis (0.025 - 0.0012 = 0.0238) under the null hypothesis.
# Example 2 ---- # Usage of title = ..., subtitle = ... # to edit the title/subtitle gs_power_wlr(lpar = list(sf = gsDesign::sfLDOF, total_spend = 0.1)) %>% summary() %>% as_gt( title = "Bound Summary", subtitle = "from gs_power_wlr" )
Bound Summary
from gs_power_wlr
Bound Z Nominal p1 ~wHR at bound2
Cumulative boundary crossing probability
Alternate hypothesis Null hypothesis
Analysis: 1 Time: 14.9 N: 108 Events: 30 AHR: 0.79 Information fraction: 0.63
Futility -1.17 0.8798 1.5353 0.0341 0.1202
Efficacy 2.68 0.0037 0.3765 0.0217 0.0037
Analysis: 2 Time: 19.2 N: 108 Events: 40 AHR: 0.75 Information fraction: 0.83
Futility -0.66 0.7452 1.2319 0.0664 0.2664
Efficacy 2.29 0.0110 0.4846 0.0886 0.0121
Analysis: 3 Time: 24.5 N: 108 Events: 50 AHR: 0.71 Information fraction: 13
Futility -0.22 0.5881 1.0650 0.1002 0.4319
Efficacy 2.03 0.0212 0.5631 0.2071 0.0250
1 One-sided p-value for experimental vs control treatment. Value < 0.5 favors experimental, > 0.5 favors control.
2 Approximate hazard ratio to cross bound.
3 wAHR is the weighted AHR.
# Example 3 ---- # Usage of colname_spanner = ..., colname_spannersub = ... # to edit the spanner and its sub-spanner gs_power_wlr(lpar = list(sf = gsDesign::sfLDOF, total_spend = 0.1)) %>% summary() %>% as_gt( colname_spanner = "Cumulative probability to cross boundaries", colname_spannersub = c("under H1", "under H0") )
Bound summary for WLR design
WLR approximation of ~wHR at bound
Bound Z Nominal p1 ~wHR at bound2
Cumulative probability to cross boundaries
under H1 under H0
Analysis: 1 Time: 14.9 N: 108 Events: 30 AHR: 0.79 Information fraction: 0.63
Futility -1.17 0.8798 1.5353 0.0341 0.1202
Efficacy 2.68 0.0037 0.3765 0.0217 0.0037
Analysis: 2 Time: 19.2 N: 108 Events: 40 AHR: 0.75 Information fraction: 0.83
Futility -0.66 0.7452 1.2319 0.0664 0.2664
Efficacy 2.29 0.0110 0.4846 0.0886 0.0121
Analysis: 3 Time: 24.5 N: 108 Events: 50 AHR: 0.71 Information fraction: 13
Futility -0.22 0.5881 1.0650 0.1002 0.4319
Efficacy 2.03 0.0212 0.5631 0.2071 0.0250
1 One-sided p-value for experimental vs control treatment. Value < 0.5 favors experimental, > 0.5 favors control.
2 Approximate hazard ratio to cross bound.
3 wAHR is the weighted AHR.
# Example 4 ---- # Usage of footnote = ... # to edit the footnote gs_power_wlr(lpar = list(sf = gsDesign::sfLDOF, total_spend = 0.1)) %>% summary() %>% as_gt( footnote = list( content = c( "approximate weighted hazard ratio to cross bound.", "wAHR is the weighted AHR.", "the crossing probability.", "this table is generated by gs_power_wlr." ), location = c("~wHR at bound", NA, NA, NA), attr = c("colname", "analysis", "spanner", "title") ) )
Bound summary for WLR design1
WLR approximation of ~wHR at bound
Bound Z Nominal p ~wHR at bound3
Cumulative boundary crossing probability2
Alternate hypothesis Null hypothesis
Analysis: 1 Time: 14.9 N: 108 Events: 30 AHR: 0.79 Information fraction: 0.64
Futility -1.17 0.8798 1.5353 0.0341 0.1202
Efficacy 2.68 0.0037 0.3765 0.0217 0.0037
Analysis: 2 Time: 19.2 N: 108 Events: 40 AHR: 0.75 Information fraction: 0.84
Futility -0.66 0.7452 1.2319 0.0664 0.2664
Efficacy 2.29 0.0110 0.4846 0.0886 0.0121
Analysis: 3 Time: 24.5 N: 108 Events: 50 AHR: 0.71 Information fraction: 14
Futility -0.22 0.5881 1.0650 0.1002 0.4319
Efficacy 2.03 0.0212 0.5631 0.2071 0.0250
1 this table is generated by gs_power_wlr.
2 the crossing probability.
3 approximate weighted hazard ratio to cross bound.
4 wAHR is the weighted AHR.
# Example 5 ---- # Usage of display_bound = ... # to either show efficacy bound or futility bound, or both(default) gs_power_wlr(lpar = list(sf = gsDesign::sfLDOF, total_spend = 0.1)) %>% summary() %>% as_gt(display_bound = "Efficacy")
Bound summary for WLR design
WLR approximation of ~wHR at bound
Bound Z Nominal p1 ~wHR at bound2
Cumulative boundary crossing probability
Alternate hypothesis Null hypothesis
Analysis: 1 Time: 14.9 N: 108 Events: 30 AHR: 0.79 Information fraction: 0.63
Efficacy 2.68 0.0037 0.3765 0.0217 0.0037
Analysis: 2 Time: 19.2 N: 108 Events: 40 AHR: 0.75 Information fraction: 0.83
Efficacy 2.29 0.0110 0.4846 0.0886 0.0121
Analysis: 3 Time: 24.5 N: 108 Events: 50 AHR: 0.71 Information fraction: 13
Efficacy 2.03 0.0212 0.5631 0.2071 0.0250
1 One-sided p-value for experimental vs control treatment. Value < 0.5 favors experimental, > 0.5 favors control.
2 Approximate hazard ratio to cross bound.
3 wAHR is the weighted AHR.
# Example 6 ---- # Usage of display_columns = ... # to select the columns to display in the summary table gs_power_wlr(lpar = list(sf = gsDesign::sfLDOF, total_spend = 0.1)) %>% summary() %>% as_gt(display_columns = c("Analysis", "Bound", "Nominal p", "Z", "Probability"))
Bound summary for WLR design
WLR approximation of ~wHR at bound
Bound Nominal p1 Z
Cumulative boundary crossing probability
Alternate hypothesis Null hypothesis
Analysis: 1 Time: 14.9 N: 108 Events: 30 AHR: 0.79 Information fraction: 0.62
Futility 0.8798 -1.17 0.0341 0.1202
Efficacy 0.0037 2.68 0.0217 0.0037
Analysis: 2 Time: 19.2 N: 108 Events: 40 AHR: 0.75 Information fraction: 0.82
Futility 0.7452 -0.66 0.0664 0.2664
Efficacy 0.0110 2.29 0.0886 0.0121
Analysis: 3 Time: 24.5 N: 108 Events: 50 AHR: 0.71 Information fraction: 12
Futility 0.5881 -0.22 0.1002 0.4319
Efficacy 0.0212 2.03 0.2071 0.0250
1 One-sided p-value for experimental vs control treatment. Value < 0.5 favors experimental, > 0.5 favors control.
2 wAHR is the weighted AHR.
# }