The goal of goldilocks is to implement the Goldilocks Bayesian adaptive design proposed by Broglio et al. (2014), for both one- and two-arm trials. Outcomes are generated from an underlying piecewise-exponential event-time model. Final analyses may retain the time-to-event outcome or reduce complete follow-up to event status at a fixed endpoint time.
The method can be used for a confirmatory trial to select a trial’s sample size based on accumulating data. During accrual, frequent sample size selection analyses are made and predictive probabilities are used to determine whether the current sample size is sufficient or whether continuing accrual would be futile. The algorithm explicitly accounts for complete follow-up of all patients before the primary analysis is conducted. Time-to-event final analyses include the log-rank test, Cox proportional hazards regression Wald test, restricted mean survival time (RMST) difference Wald test, and Bayesian piecewise-exponential inference. Fixed-time binary final analyses include frequentist risk-difference Wald and Farrington-Manning score tests, and Bayesian beta-binomial inference.
Broglio et al. (2014) refer to this as a Goldilocks trial design, as it is constantly asking the question, “Is the sample size too big, too small, or just right?”
Endpoint and analysis options
All designs use the piecewise-exponential event-time model for simulation and predictive imputation. The method argument selects the final analysis:
"logrank": log-rank test for a two-arm time-to-event endpoint"cox": Cox model Wald test for a two-arm time-to-event endpoint"rmst": RMST difference Wald test for two arms at a prespecifiedrmst_tau(defaults toend_of_study); positive differences favor longer event-free time"bayes-surv": Bayesian piecewise-exponential analysis for one- or two-arm time-to-event endpoints"riskdiff-wald": frequentist Wald test for a two-arm fixed-time binary event-risk difference"riskdiff-fm": Farrington-Manning score test for a two-arm fixed-time binary event-risk difference, including sparse outcomes"bayes-bin": Bayesian beta-binomial analysis for one- or two-arm fixed-time binary endpoints
The former "riskdiff" option remains available as a deprecated alias for "riskdiff-wald" and emits a warning.
See the package vignettes for worked two-arm, single-arm, piecewise survival, RMST, and Bayesian binary examples. For RMST use alternative = "greater" to test longer event-free time and express h0 in the same time units as follow-up.
For method = "bayes-surv", prior_surv generates predictive outcomes, while prior_surv_final tests each hypothetical completed trial at the interim look and governs the actual final analysis. To incorporate external evidence only in prediction, supply both priors explicitly. Omitting prior_surv_final uses prior_surv for both roles. Bayesian binary success tests instead use prior_bin. See the worked example of separate priors.
Key benefits
Other software and R packages are available to implement this algorithm. However, when designing studies it is generally required that many thousands of trials are simulated to adequately characterize the operating characteristics, e.g. type I error and power. Hence, a computationally efficient and fast algorithm is helpful. The goldilocks package takes advantage of many tools to achieve this:
Log-rank tests are implemented via a lightweight C++ implementation originally from the
fastlogranktestpackage. Sincefastlogranktesthas been deprecated and removed from CRAN, a copy of the C++ source code has been ported directly intogoldilocksPiecewise exponential simulation is implemented via the
PWEALLpackage, which uses a lightweight Fortran implementationSimulation of multiple trials can be performed in parallel on Unix-like platforms or Windows using R’s parallel backends
References
Broglio KR, Connor JT, Berry SM. Not too big, not too small: a Goldilocks approach to sample size selection. Journal of Biopharmaceutical Statistics, 2014; 24(3): 685–705.
Installation
The source version is goldilocks 1.0.0, prepared for CRAN submission. See NEWS.md for changes and migration guidance from 0.6.0.
You can install the released version of goldilocks from CRAN with:
install.packages("goldilocks")You can install the current source version from GitHub with:
# install.packages("devtools")
devtools::install_github("graemeleehickey/goldilocks")