ThegsDesign package was originally designed to havecontinuous sample size planned rather than integer-based sample size.Designs with time-to-event outcomes also had non-integer event counts attimes of analysis. This vignette documents the capability to convert tointeger sample sizes and event counts. This has a couple of implicationson design characteristics:
This document goes through examples to demonstrate the calculations.The new function as of July 2023 is thetoInteger() whichoperates on group sequential designs to convert to integer-based totalsample size and event counts at analyses. As of November 2024, therounding defaults are changing as documented below. We begin with asummary of the method. Then we provide an abbreviated example for atime-to-event endpoint design to demonstrate basic concepts. We followwith a more extended example for a binary endpoint to explain moredetails.
## [1] 165.0263 330.0526 495.0789## [1] 165 330 496## [1] 510.9167 730.7015 730.7015# Rounded up to even final sample size given that x$ratio = 1# and rounding to multiple of x$ratio + 1as.numeric(y$eNE+ y$eNC)## [1] 511.2601 732.0000 732.0000# With roundUpFinal = FALSE, final sample size rounded to nearest integerz<- x|>toInteger(roundUpFinal =FALSE)as.numeric(z$eNE+ z$eNC)## [1] 510.6594 730.0000 730.0000ratio is a positive integer, the final sample sizeis rounded to a multiple ofratio + 1.ratio = 1 to round to an even sample size.ratio = 2 to round to amultiple of 3.ratio = 4 to round to amultiple of 5.ratio + 1 whenroundUpFinal = TRUE is specified. IfroundUpFinal = FALSE, the final sample size is rounded tothe nearest multiple ofratio + 1.We present a simple example based on comparing binomial rates withinterim analyses after 50% and 75% of events. We assume a 2:1experimental:control randomization ratio. Note that the sample size isnot an integer. We target 80% power (beta = .2).
## [1] 429.8846If we replace thebeta argument above with a integersample size that is a multiple of 3 so that we get the desired 2:1integer sample sizes per arm (432 = 144 control + 288 experimentaltargeted) we get slightly larger than the targeted 80% power:
## [1] 0.801814Now we convert the fixed sample sizen.fix from above toa 1-sided group sequential design with interims after 50% and 75% ofobservations. Again, sample size at each analysis is not an integer. Weuse the Lan-DeMets spending function approximating an O’Brien-Flemingefficacy bound.
# 1-sided design (efficacy bound only; test.type = 1)xb<-gsDesign(alpha = .025,beta = .2,n.fix = n.fix,test.type =1,sfu = sfLDOF,timing =c(.5, .75))# Continuous sample size (non-integer) at planned analysesxb$n.I## [1] 219.1621 328.7432 438.3243Next we convert to integer sample sizes at each analysis. Interimsample sizes are rounded to the nearest integer. The defaultroundUpFinal = TRUE rounds the final sample size to thenearest integer to 1 + the experimental:control randomization ratio.Thus, the final sample size of 441 below is a multiple of 3.
# Convert to integer sample size with even multiple of ratio + 1# i.e., multiple of 3 in this case at final analysisx_integer<-toInteger(xb,ratio =2)x_integer$n.I## [1] 219 329 441Next we examine the efficacy bound of the 2 designs as they areslightly different.
## [1] 2.962588 2.359018 2.014084## [1] 2.974067 2.366106 2.012987The differences are associated with slightly different timing of theanalyses associated with the different sample sizes noted above:
## [1] 0.50 0.75 1.00## [1] 0.4965986 0.7460317 1.0000000These differences also make a difference in the cumulative Type Ierror associated with each analysis as shown below.
## [1] 0.001525323 0.009649325 0.025000000# Specified spending based on the spending functionxb$upper$sf(alpha = xb$alpha,t = xb$timing, xb$upper$param)$spend## [1] 0.001525323 0.009649325 0.025000000## [1] 0.001469404 0.009458454 0.025000000# Specified spending based on the spending function# Slightly different from continuous design due to slightly different information fractionx$upper$sf(alpha = x_integer$alpha,t = x_integer$timing, x_integer$upper$param)$spend## [1] 0.01547975 0.02079331 0.02500000Finally, we look at cumulative boundary crossing probabilities underthe alternate hypothesis for each design. Due to rounding up the finalsample size, the integer-based design has slightly higher total powerthan the specified 80% (Type II errorbeta = 0.2.). Interimpower is slightly lower for the integer-based design since sample sizeis rounded to the nearest integer rather than rounded up as at the finalanalysis.
# Cumulative upper boundary crossing probability under alternate by analysis# under alternate hypothesis for continuous sample sizecumsum(xb$upper$prob[,2])## [1] 0.1679704 0.5399906 0.8000000## [1] 0.1649201 0.5374791 0.8025140The defaulttest.type = 4 has a non-binding futilitybound. We examine behavior of this design next. The futility bound ismoderately aggressive and, thus, there is a compensatory increase insample size to retain power. The parameterdelta1 is thenatural parameter denoting the difference in response (or failure) ratesof 0.2 vs. 0.1 that was specified in the call tonBinomial() above.
# 2-sided asymmetric design with non-binding futility bound (test.type = 4)xnb<-gsDesign(alpha = .025,beta = .2,n.fix = n.fix,test.type =4,sfu = sfLDOF,sfl = sfHSD,sflpar =-2,timing =c(.5, .75),delta1 = .1)# Continuous sample size for non-binding designxnb$n.I## [1] 231.9610 347.9415 463.9219As before, we convert to integer sample sizes at each analysis andsee the slight deviations from the interim timing of 0.5 and 0.75.
## [1] 232 348 465## [1] 0.4989247 0.7483871 1.0000000These differences also make a difference in the Type I errorassociated with each analysis
## [1] 0.001525323 0.009630324 0.023013764## [1] 0.001507499 0.009553042 0.022999870The Type I error ignoring the futility bounds just shown does not usethe full targeted 0.025 as the calculations assume the trial stops forfutility if an interim futility bound is crossed. The non-binding Type Ierror assuming the trial does not stop for futility is:
## [1] 0.001507499 0.009571518 0.025000000Finally, we look at cumulative lower boundary crossing probabilitiesunder the alternate hypothesis for the integer-based design and compareto the planned\(\beta\)-spending. Wenote that the final Type II error spending is slightly lower than thetargeted 0.2 due to rounding up the final sample size.
## [1] 0.05360549 0.10853733 0.19921266# Spending function target is the same at interims, but larger at finalxnbi$lower$sf(alpha = xnbi$beta,t = xnbi$n.I/max(xnbi$n.I),param = xnbi$lower$param)$spend## [1] 0.05360549 0.10853733 0.20000000The\(\beta\)-spending lower than0.2 in the first row above is due to the final sample size powering thetrial to greater than 0.8 as seen below.
## [1] 0.8007874