Simulates one single-arm or randomized two-arm trial under a Goldilocks sample-size design. At each planned interim look, posterior predictive probabilities determine whether to declare immediate success, stop accrual for expected success, stop for futility, or continue toward the maximum sample size.
Usage
survival_adapt(
hazard_treatment,
hazard_control = NULL,
cutpoints = NULL,
N_total,
lambda = 0.3,
lambda_time = NULL,
interim_look = NULL,
end_of_study,
prior_surv = c(0.1, 0.1),
prior_bin = c(1, 1),
bin_method = "mc",
block = 2,
rand_ratio = c(control = 1, treatment = 1),
prop_loss = 0,
alternative = "greater",
h0 = 0,
Fn = 0.05,
Sn = 0.9,
prob_ha = 0.95,
N_impute = 500,
N_mcmc = 1000,
mc_conf_level = 0.95,
empty_interval = c("prior", "propagate", "error"),
method = "logrank",
imputed_final = FALSE,
return_trace = FALSE,
binary_imputation = c("event-time", "bernoulli"),
prior_surv_final = prior_surv,
generation_cutpoints = cutpoints,
Qn = 1,
rmst_tau = end_of_study
)Arguments
- hazard_treatment
A required numeric vector of finite, non-negative event rates for the treatment arm. Supply one rate per interval defined by
generation_cutpoints; a single value specifies a constant event rate.- hazard_control
NULL(the default) for a single-arm trial, or a numeric vector of finite, non-negative event rates for the control arm in a two-arm trial. It must contain one rate per interval defined bygeneration_cutpoints.- cutpoints
NULL(the default), or a numeric vector of finite, positive, strictly increasing interior follow-up times defining the piecewise-exponential model used for interim posterior estimation, predictive imputation, and final analysis. The number of interval-specific prior columns must be one greater than the number of cutpoints.NULLspecifies a constant-hazard analysis model.- N_total
A required positive integer giving the maximum total sample size.
- lambda
A numeric vector of finite, positive enrollment rates per unit of calendar time. Supply one rate for each interval defined by
lambda_time. The default is0.3. Seeenrollment()for the continuous-time enrollment model and time origin.- lambda_time
NULL(the default), or a numeric vector of finite, positive, strictly increasing calendar times at which the enrollment rate changes. Time zero is implicit, andlength(lambda)must equallength(lambda_time) + 1.- interim_look
NULL(the default) for no interim analyses, or a strictly increasing positive integer vector giving the cumulative sample size at each interim look. Do not include the maximum sample size. For two-arm designs, each interim look must be at least the (largest) block size (seeblock), ensuring both treatment groups are present at every interim analysis; a smaller look could enroll subjects from one treatment group only, leaving the interim posterior undefined for the missing group.- end_of_study
A required finite, positive numeric value giving the planned subject-level follow-up time. It must be greater than the final value in both
cutpointsandgeneration_cutpoints, when supplied, and use the same time unit.- prior_surv
A numeric vector, matrix, or named list specifying the Gamma prior for the piecewise-exponential hazards used to generate outcomes during interim prediction. A length-two vector supplies shape and rate and applies the same prior to every arm and interval. A
2bylength(cutpoints) + 1matrix supplies interval-specific values shared by all arms, with shapes in row 1 and rates in row 2. For independent arm-specific priors, supply a list namedcontrolandtreatmentin a two-arm design, ortreatmentin a single-arm design. Each list element may be a length-two vector or an interval-specific matrix. Both arms must be supplied; no values are borrowed or filled from the other arm. Rates must use the same time unit as event times, exposure, and cutpoints. The default isc(0.1, 0.1).- prior_bin
A length-two numeric vector of finite, positive shape parameters
c(a, b)for theBeta(a, b)event-probability prior used whenmethod = "bayes-bin". The same prior is applied to both arms. The default isc(1, 1), a uniform prior.- bin_method
A single character string selecting how to calculate the posterior probability for
method = "bayes-bin". It must be one of"mc"(Monte Carlo sampling),"normal"(normal approximation), or"quadrature"(numerical integration). The default is"mc". The normal approximation can be inaccurate with sparse events or non-events and posterior event probabilities near 0 or 1. It can change whetherprob_hais exceeded. IncreasingN_mcmcdoes not improve this approximation; use"quadrature"or sufficiently precise"mc"instead.- block
A positive integer vector of permitted randomization block sizes. Every value must be a multiple of
sum(rand_ratio). The default is2and the argument is ignored for a single-arm trial.- rand_ratio
A length-two positive integer vector giving the control to treatment randomization ratio. The default is
c(control = 1, treatment = 1). Name the valuescontrolandtreatment; either supplied order is accepted and matched by name. A legacy unnamed vector remains accepted inc(control, treatment)order. Unequal unnamed values produce a warning because names may be required in a future major release. Seerandomization()for more details.- prop_loss
A numeric vector containing one or two probabilities in
[0, 1). Each value is the dropout-time CDF atend_of_study: \(P(D \le \tau) = p\), where \(\tau\) is the planned follow-up duration per subject. Independently of event time and enrollment, each subject's dropout time \(D\) is exponentially distributed with rate \(-\log(1-p)/\tau\). The observed time is the minimum of event time, dropout time, andend_of_study; an event occurring before dropout is retained. Thus,prop_lossis not the expected proportion actually censored by dropout: that proportion can be lower because events occur first, and the realized number of dropouts varies between trials. A single value applies the same dropout distribution to every arm. For a two-arm design, supply a length-two vector namedcontrolandtreatmentfor arm-specific probabilities; supplied order does not matter. Single-arm designs require one probability. The default0sets dropout time to infinity without drawing random numbers. A value of1is rejected because it requires an infinite exponential rate.- alternative
A single character string specifying the alternative hypothesis. It must be one of
"greater"(the default),"less", or"two.sided". One-sided alternatives ("greater"and"less") are supported formethod = "bayes-surv"andmethod = "bayes-bin". All three options are supported formethod = "logrank",method = "cox",method = "rmst",method = "riskdiff-wald", andmethod = "riskdiff-fm". For an adverse event, benefit is in the"greater"direction for RMST (longer event-free time) and the"less"direction for the other methods (lower hazard or event probability).- h0
A single finite numeric value specifying the null hypothesis or margin. The default is
0. For Bayesian analyses,h0must lie in[0, 1]for a single-arm design and[-1, 1]for a two-arm design.When
method = "bayes-surv",h0is the null value of \(p_\textrm{treatment} - p_\textrm{control}\). In a single-arm design,h0is the external benchmark event probability, often referred to as a performance goal (PG) or objective performance criterion (OPC).When
method = "bayes-bin",h0is the null value of \(p_\textrm{treatment} - p_\textrm{control}\) for a two-arm design, or the null event probability for a single-arm design.When
method = "cox",h0is the null log hazard ratio for treatment versus control. Useh0 = 0for the usual hazard ratio of 1 null, orh0 = log(margin)for a non-inferiority margin specified as a hazard ratio. A Cox non-inferiority test should usually usealternative = "less".When
method = "rmst",h0is the null treatment-control RMST difference in time units and must lie in[-rmst_tau, rmst_tau]. For non-inferiority allowing a loss ofmtime units, useh0 = -mandalternative = "greater".When
method = "riskdiff-wald"ormethod = "riskdiff-fm",h0is the null value of \(p_\textrm{treatment} - p_\textrm{control}\) and must lie in[-1, 1].When
method = "logrank", onlyh0 = 0is supported; this denotes the usual equal-survival null. Nonzero values are rejected because the standard log-rank statistic does not implement a nonzero effect margin.
- Fn
NULL, or a numeric vector of probabilities in[0, 1]. Each value is the predictive-probability threshold to stop at the \(i\)-th look early for futility. If there are no interim looks (i.e.interim_look = NULL), thenFnis not used in the simulations or analysis. SetFn = 0to disable futility monitoring;Fn = NULLhas the same effect. Supply either one value, which is repeated at every interim look, or exactly one value perinterim_look. Other lengths are rejected rather than recycled. The default is0.05.- Sn
A numeric vector of probabilities in
[0, 1]. Each value is the predictive-probability threshold to stop accrual at the \(i\)-th look for expected success. If there are no interim looks (i.e.interim_look = NULL), thenSnis not used in the simulations or analysis. Supply either one value, which is repeated at every interim look, or exactly one value perinterim_look. Other lengths are rejected rather than recycled. The default is0.9.- prob_ha
A single numeric probability in
[0, 1]defining success in each completed-data analysis. For Bayesian methods this is compared with the posterior probability of the alternative; for frequentist methods it is compared with1 - P. The default is0.95.- N_impute
A positive integer giving the number of predictive imputations used at each interim look and, when requested, for final multiple imputation. The default is
500. An imputed Cox, RMST, or risk-difference final analysis requires at least two.- N_mcmc
A positive integer giving the number of posterior draws used within each
method = "bayes-surv"and bymethod = "bayes-bin"whenbin_method = "mc". The default is1000.- mc_conf_level
A single numeric probability strictly between
0.5and1, giving the confidence level for one-sided exact binomial bounds reported as diagnostics of finite Monte Carlo uncertainty. The bounds do not alter completed-data success classifications or interim decisions, which use strict point-estimate comparisons withprob_ha,Qn,Sn, andFn. The default is0.95.- empty_interval
A single character string specifying how to handle empty piecewise-exponential intervals when updating Gamma hazard models for predictive imputation and Bayesian survival analysis. An empty interval is an interval with no exposed subjects in a treatment arm at the analysis time.
"prior"(the default) leaves the interval at zero exposure time and zero events, so its posterior is driven only by its assigned survival prior."propagate"is a legacy heuristic that copies exposure time and event counts from the nearest non-empty interval in the same treatment arm and emits a warning."error"stops when any empty interval is found.- method
A single character string specifying the completed-data and final analysis. Available choices are a log-rank (
method = "logrank") test, Cox proportional hazards regression model Wald test (method = "cox"), a restricted mean survival time difference Wald test (method = "rmst"), a fully-Bayesian piecewise-exponential analysis (method = "bayes-surv"), a Bayesian beta-binomial analysis of complete binary outcomes (method = "bayes-bin"), a frequentist risk-difference Wald test (method = "riskdiff-wald"), or a Farrington-Manning score test (method = "riskdiff-fm") of complete binary outcomes. The deprecatedmethod = "riskdiff"is accepted as an alias for"riskdiff-wald"with a warning. The default is"logrank". See Details.- imputed_final
A single logical value indicating whether the final analysis should be based on imputed outcomes for subjects who were LTFU (i.e. right-censored with time less than
end_of_study). The default isFALSE, which uses the observed-data analysis. If no outcomes require imputation, the selected complete-data test is used directly with either flag. With missing outcomes andmethod = "cox","rmst", or"riskdiff-wald", setting this toTRUEpools the scalar treatment effects and variances using Rubin's rules; this requiresN_impute >= 2and positive total variance. Genuine final imputation is unsupported formethod = "riskdiff-fm"because no validated FM pooling rule is implemented. Simulations combining FM andimputed_final = TRUEtherefore requireprop_loss = 0in both arms. Imputed final analyses remain unavailable formethod = "logrank".- return_trace
A single logical value indicating whether the interim decision path should be returned in addition to the usual final summary. The default,
FALSE, returns the historical one-row data frame. WhenTRUE, the result is agoldilocks_trialobject with summary, trace, prior and posterior diagnostics, and call elements.- binary_imputation
A single character string selecting the predictive imputation approach for
method = "bayes-bin",method = "riskdiff-wald", ormethod = "riskdiff-fm"."event-time"(the default) draws a conditional piecewise-exponential event time and reduces it to event status atend_of_study."bernoulli"draws the endpoint status directly from its conditional event probability. This argument is ignored for time-to-event analysis methods.- prior_surv_final
A numeric vector, matrix, or named list specifying the Gamma prior used for final-stage piecewise-exponential imputation and, for
method = "bayes-surv", both the analysis of each hypothetical completed trial at interim looks and the actual final analysis. It accepts the same shared or arm-specific forms asprior_survand defaults toprior_surv. An informativeprior_survcan therefore predict outstanding outcomes while a weakprior_surv_finaldefines the Bayesian survival success criterion. To use different priors for these roles, supplyprior_surv_finalexplicitly; an informative predictive prior is otherwise also the default analysis prior. See Predictive and analysis priors below.- generation_cutpoints
NULL, or a numeric vector of finite, positive, strictly increasing interior follow-up times defining the piecewise-exponential model used to generate event times.hazard_treatmentandhazard_controlmust each have one value per resulting interval. Defaults tocutpoints, preserving the historical behavior in which generation and analysis used one partition.- Qn
A numeric vector of probabilities in
[0, 1]. Each value is the upper predictive-probability threshold for declaring immediate trial success at the \(i\)-th look. If there are no interim looks (i.e.interim_look = NULL), thenQnis not used in the simulations or analysis. Supply either one value, which is repeated at every interim look, or exactly one value perinterim_look; other lengths are rejected.Qnmust be greater than or equal toSnat every look. The default,1, disables immediate-success stopping.- rmst_tau
A single finite positive restriction time for
method = "rmst", in the same units asend_of_study. Defaults toend_of_studyand must not exceed it. Prespecify the same horizon for all looks, imputations, and simulations. It may precede analysis cutpoints and does not shorten the planned follow-up or imputation horizon. Ignored for other methods.
Value
With return_trace = FALSE (the default), a one-row data frame
containing the evaluated design and final trial results, including:
N_treatment: Number of patients enrolled in the treatment arm.N_control: Number of patients enrolled in the control arm.est_final: Treatment effect estimated at the final analysis. For RMST this is treatment minus control RMST throughrmst_tau, in time units. The final analysis occurs when either the maximum sample size is reached and follow-up is complete, or the interim analysis triggered early stopping of enrollment/accrual and follow-up for those subjects is complete. It isNAafter an immediate-success decision, for which no later analysis is required, or when the optional diagnostic analysis after binding futility cannot be computed.post_prob_ha: Posterior probability from the final analysis. If a Bayesian method usesimputed_final = TRUE, this is calculated for each imputed final-analysis dataset and averaged overN_imputeimputations. For an imputed Cox analysis it is \(1 - P\) from the Rubin-pooled Wald test. The same interpretation applies to imputed RMST and risk-difference analyses. For non-imputed frequentist analyses it is \(1 - P\) from the corresponding test. It isNAafter an immediate-success decision, for which no later analysis is required, or when the optional diagnostic analysis after binding futility cannot be computed.stop_futility: Logical indicator of whether the trial stopped early for binding futility.stop_immediate_success: Logical indicator of whether the trial stopped and declared immediate success at an interim look.stop_expected_success: Logical indicator of whether the trial stopped accruing for expected success and continued planned follow-up.trial_success: Logical indicator of the trial's official success outcome. An immediate-success decision is final at the interim look; binding futility is a final failure.stopping_reason: One of"immediate_success","expected_success","futility", or"maximum_sample_size".decision_time: Calendar time at which the trial decision becomes final. This is the interim look time for immediate success or futility, and the analysis-ready time otherwise.accrual_stop_time: Calendar time of the last enrollment in the trial.analysis_ready_time: Calendar time at which the last enrolled subject's observed event or censoring becomes available. This excludes external data-cleaning and database-lock delays.planned_completion_time: Calendar time at which the last enrolled subject would complete the full planned follow-up.followup_person_time: Sum of observed follow-up times across enrolled subjects.peak_active_followup: Largest number of enrolled subjects concurrently under follow-up.
Calendar time is measured from the first patient's enrollment at time zero.
Times use the same units as lambda_time, cutpoints,
generation_cutpoints, and end_of_study.
The returned object has a decision_design attribute containing
interim_look, Fn, Sn, Qn, and the Monte Carlo settings. Thresholds
in this information are stored as one value per interim look (and have
length zero when no interim looks are planned). A prior_design attribute
contains the resolved Gamma shape, rate, mean hazard, and standard
deviation for every stage, arm, and interval.
Both return forms have an arguments attribute containing a named list of
the evaluated argument values, including defaults. It can be saved with
saveRDS() and supplied to a later call with
do.call(survival_adapt, attr(result, "arguments")). Its prop_loss
element contains a named value for every simulated arm. Its rand_ratio
element is stored in control, treatment order for two-arm designs. Its
cutpoints and generation_cutpoints elements retain the analysis and
data-generation partitions, respectively. For method = "bayes-bin", this
metadata explicitly retains the imputation priors (prior_surv and
prior_surv_final), completed-data analysis prior (prior_bin), and
imputation horizon (end_of_study). The separate prior_design attribute
gives the resolved Gamma parameters by stage, arm, and interval.
With return_trace = TRUE, a goldilocks_trial object is returned. Its
summary element is the same data frame and its trace element has one
row per interim look. prior_diagnostics contains the resolved interim and
final priors. posterior_diagnostics reports observed and effective
sufficient statistics and conjugate posterior parameters by completed look,
arm, and interval. The trace records calendar time, the number of subjects
actively under follow-up, enrollment and observed events by arm, predictive
probabilities, diagnostic Monte Carlo standard errors and exact bounds,
draw counts, thresholds, the decision and reason, empty-interval fallback
diagnostics, and warnings raised during that look. It deliberately excludes
imputed data sets and posterior draws to keep the output compact.
Details
Implements the Goldilocks design method described in Broglio et al. (2014). At each interim analysis, two probabilities are computed:
The posterior predictive probability of eventual success. This is calculated as the proportion of imputed datasets at the current sample size that satisfy the completed-data success criterion. At each interim analysis this proportion is first compared to the corresponding element of
Qn. If it is strictly greater thanQn, the trial stops and declares immediate success. Otherwise, if it is strictly greater thanSn, accrual/enrollment is suspended and the outstanding follow-up is allowed to complete before conducting the pre-specified final analysis.The posterior predictive probability of success at the maximum sample size. This is calculated as the proportion of imputed datasets at the maximum sample size that satisfy the completed-data success criterion. It is compared to the corresponding element of
Fn, and if it is below the threshold, accrual/enrollment is suspended and the trial terminated. Typically this would be a binding decision. If it is not a binding decision, then one should also explore the simulations withFn = 0.
Hence, each interim look has four possible decisions, applied in this order:
Stop and declare immediate success when \(P_{n,l} > Q_l\).
Stop accruing for expected success and follow when \(S_l < P_{n,l} \le Q_l\).
Stop for futility when \(P_{n_{max},l} < F_l\).
Continue to enroll new subjects, or if at maximum sample size, proceed to final analysis.
The following completed-data analysis methods are available at interim and final analyses:
Log-rank test (
method = "logrank"). Each (imputed) dataset with both treatment and control arms can be compared using a standard log-rank test. The output is a P-value, and there is no treatment effect reported. The function returns \(1 - P\), which is reported inpost_prob_ha. Whilst not a posterior probability, it can be contrasted in the same manner. For example, if the success threshold is \(P < 0.05\), then one requirespost_prob_ha\(> 0.95\). The reason for this is to enable simple switching between Bayesian and frequentist paradigms for analysis. Whenalternative = "less"or"greater", a one-sided P-value is computed from the log-rank z-statistic.Cox proportional hazards regression Wald test (
method = "cox"). Similar to the log-rank test, a P-value is calculated and \(1 - P\) is reported inpost_prob_ha. Whenalternative = "two.sided", the standard two-sided Wald P-value is used whenh0 = 0. For other values ofh0, the Wald test is centered on the specified null log hazard ratio. Whenalternative = "less"or"greater", a one-sided P-value is derived from the Wald z-statistic relative toh0. The treatment effect (log hazard ratio) is also reported. Whenimputed_final = TRUEand outcomes are missing, the Cox model is fitted to each of at least two imputed datasets. The log hazard ratios and their within-imputation variances are combined using Rubin's rules; the pooled Wald test uses Rubin's large-sample degrees of freedom. Whenimputed_final = FALSE, the existing single Cox model is fitted directly to the observed right-censored data.Restricted mean survival time (
method = "rmst"). Estimates the area under each Kaplan-Meier survival curve from zero through the prespecifiedrmst_tau. The effect is treatment minus control RMST, measured in time units. The Wald test uses the sum of the independent arm-specific Greenwood variances and reports \(1 - P\). All three alternatives and nonzero margins are supported. For an adverse event, a positive difference favors treatment. Observed censored subjects remain in the analysis. An arm whose last follow-up precedesrmst_tauwith positive estimated survival makes the analysis non-estimable; the horizon is never reduced automatically. A curve reaching zero earlier is allowed. The test requires positive total variance, including after Rubin pooling forimputed_final = TRUE. This unadjusted two-arm analysis does not assume proportional hazards. Interim prediction and final imputation still depend on the specified piecewise-exponential model. Seevignette("rmst", package = "goldilocks").Bayesian difference in cumulative event probability (
method = "bayes-surv"). Each imputed dataset is used to update the conjugate Gamma analysis priorprior_surv_final, at both interim looks and the final stage, yielding a posterior distribution for the piecewise exponential rate parameters. In turn, the posterior distribution of the cumulative incidence function (\(1 - S(t)\), where \(S(t)\) is the survival function) evaluated at timeend_of_studyis calculated. In a single-arm study, inference concerns the treatment-arm event probability. In a two-arm study, the independent arm-specific posteriors define the posterior distribution of the treatment-minus-control difference. The reported posterior probability is determined byalternativeandh0.For piecewise-exponential analyses, an interim or final dataset may contain intervals with no exposed subjects in one treatment arm, especially when later cutpoints occur after the available follow-up at early looks. The
empty_intervalargument controls this case. The default,"prior", leaves an empty interval prior-driven, making the absence of interval data explicit. The legacy"propagate"option borrows sufficient statistics from the nearest non-empty interval within the same treatment arm. It is operationally stable but statistically consequential because adjacent observed data then inform the empty interval's posterior."error"is strict and stops the simulation or analysis when an empty interval is encountered.Bayesian beta-binomial analysis (
method = "bayes-bin"). Each complete or imputed dataset is reduced to binary event outcomes atend_of_study. A conjugateBeta(a, b)prior, specified withprior_bin, is updated with the number of events and non-events in each arm. In a single-arm study, inference is based on the posterior event probability. In a two-arm study, inference is based on \(p_\textrm{treatment} - p_\textrm{control}\). This posterior probability can be calculated using Monte Carlo beta draws (bin_method = "mc"), a normal approximation ("normal"), or numerical quadrature ("quadrature"). Like the risk-difference test, this method requires complete binary outcomes: censored subjects must either be followed toend_of_study, imputed, or excluded whenimputed_final = FALSE.The normal approximation matches posterior moments but can misrepresent tail probabilities when a Beta posterior is skewed, particularly near event-probability boundaries of 0 or 1. This can change success and interim stopping decisions. Use
bin_method = "quadrature"or sufficiently precise"mc"when the approximation is unsuitable; increasingN_mcmcdoes not correct normal-approximation error.Two equivalent predictive imputation approaches are available through
binary_imputation. With"event-time", the package samples a future event time conditional on the available event-free follow-up and then records whether it falls byend_of_study. With"bernoulli", it calculates the same endpoint probability directly. If \(T\) is the observed event-free follow-up, \(T^*\) isend_of_study, \(S(t)\) is the survival function, and \(H(t)\) is the cumulative hazard, that probability is$$\Pr(X = 1 \mid T_\mathrm{event} > T) = \frac{S(T) - S(T^*)}{S(T)} = 1 - \exp\{-[H(T^*) - H(T)]\}.$$
A Bernoulli outcome is drawn with this probability. For a subject not yet enrolled, \(T = 0\); observed events are retained unchanged. Because no precise event time is generated, the imputed
timeis set toend_of_studyand only the binaryeventstatus is analyzed. Each imputation still uses a sampled posterior hazard draw, so uncertainty in the piecewise-exponential model is retained.Frequentist risk difference (
method = "riskdiff-wald"or"riskdiff-fm"). Each complete or predictively imputed dataset is reduced to binary event outcomes atend_of_study. The estimated treatment effect is \(p_\textrm{treatment} - p_\textrm{control}\)."riskdiff-wald"uses the observed arm risks in an unpooled Wald variance."riskdiff-fm"instead uses maximum likelihood arm risks constrained by the null differenceh0in a Farrington-Manning score variance. The latter remains defined for common sparse tables, including equal-arm all-zero and all-one outcomes. Both methods report \(1 - P\) inpost_prob_haand support all three alternatives. Because they require complete binary outcomes, lost-to-follow-up subjects are excluded whenimputed_final = FALSE. With genuinely missing final outcomes, only"riskdiff-wald"supportsimputed_final = TRUE: estimates and variances from at least two completed datasets are pooled using Rubin's rules, requiring positive total variance. FM final imputation is rejected rather than converted to a Wald test. With complete final outcomes, either flag preserves the selected test.Imputed final analysis (
imputed_final). The overall final analysis conducted after accrual is suspended and follow-up is complete can be analyzed on imputed datasets for Bayesian methods ("bayes-surv"and"bayes-bin"), Cox regression, RMST, and the frequentist risk-difference Wald analysis, or on the non-imputed dataset. Interim prediction completes outcomes that are not yet observed, whereas final imputation applies only to subjects right-censored because of loss to follow-up beforeend_of_study. Design evaluations should prespecify whether the final analysis imputes these outcomes and assess sensitivity to that choice, particularly when appreciable attrition is expected. Simulated dropout is independent of event time within each arm, as described underprop_loss. This supports survival analyses with right-censoring, but does not make complete-case binary analysis unbiased: early events can be observed before dropout, whereas later endpoint outcomes can be missing. Binary designs with dropout should assess model-based final imputation and its assumptions. For Cox regression and RMST the final estimates and variances are pooled with Rubin's rules. It cannot be used withmethod = "logrank".
When imputation is involved, either at interim analyses or through
imputed_final = TRUE, the package uses a two-stage impute-then-analyze
procedure. First, the piecewise-exponential model is fitted to the
observed time-to-event data and used to complete pending outcomes.
Second, each completed dataset is analyzed using the model selected by
method.
For method = "bayes-bin", these are deliberately separate models. The
imputation model has piecewise hazards with Gamma prior prior_surv (or
prior_surv_final during final imputation), whereas the completed-data
analysis has an event probability at end_of_study with Beta prior
prior_bin. The Beta prior is not derived from the Gamma prior, and the
two stages are not one joint Bayesian model. Both prior specifications can
therefore affect predictive decisions when outcomes require imputation. The
"event-time" and "bernoulli" binary-imputation options use the same
piecewise-exponential prediction model and do not change this separation.
For method = "bayes-surv", the second analysis instead forms a fresh
piecewise-exponential posterior from the completed data and
prior_surv_final. At interim looks the first stage uses prior_surv,
allowing predictive borrowing to differ from the final success criterion.
For frequentist methods ("logrank", "cox", "rmst", "riskdiff-wald",
and "riskdiff-fm"), each completed dataset uses a standard test rather
than a posterior. Imputed Cox, RMST, and risk-difference final analyses
pool estimates and variances using Rubin's rules.
At each interim look, follow-up times are masked (censored) to reflect the
calendar time of the analysis. The package treats enrollment and
randomization as occurring at the same time. Subjects enrolled at the exact
interim boundary have zero follow-up time. These times are clamped to
.Machine$double.eps (approximately \(2.2 \times 10^{-16}\)) so that
they contribute negligible but non-zero exposure to the interim posterior.
This affects at most one subject per interim look.
Predictive and analysis priors
For method = "bayes-surv", prior_surv_final is used during interim
calculations as well as at the actual final analysis. The two arguments
specify different roles, not simply different calendar stages:
| Calculation | Gamma prior used |
| At interim, generate outstanding outcomes for enrolled and future participants | prior_surv |
| At interim, test each hypothetical completed trial at the current or maximum sample size | prior_surv_final |
At final analysis, impute missing outcomes if imputed_final = TRUE | prior_surv_final |
| Analyze the actual final trial data | prior_surv_final |
Within one interim predictive replicate, first update prior_surv with the
observed events and exposure, draw hazards, and generate outstanding
outcomes. Then start a fresh analysis posterior using prior_surv_final
and the completed dataset's events and exposure. Compare its posterior
probability of the alternative with prob_ha. The proportion of replicates
that pass is the predictive probability used by Qn, Sn, and Fn.
To incorporate external evidence in prediction while using a weak analysis
prior, explicitly supply an informative prior_surv and the chosen weak
prior_surv_final. Omitting prior_surv_final uses prior_surv for
both roles; the package does not automatically weaken the analysis prior.
The predictive prior can still affect the selected sample size and stopping
decision, so calibrate the design using both prespecified priors.
This table describes Bayesian survival analysis. For
method = "bayes-bin", completed-data success tests at interim and final
use prior_bin; prior_surv_final governs only optional final imputation.
Frequentist completed-data tests use no analysis prior.
evaluate_interim() performs the two interim calculations; use the same
prior arguments as in the simulated design.
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.
Examples
# RCT with exponential hazard (no piecewise breaks)
# Note: the number of imputations is small to enable this example to run
# quickly on CRAN tests. In practice, much larger values are needed.
survival_adapt(
hazard_treatment = -log(0.85) / 36,
hazard_control = -log(0.7) / 36,
cutpoints = NULL,
N_total = 600,
lambda = 20,
lambda_time = NULL,
interim_look = 400,
end_of_study = 36,
prior_surv = c(0.1, 0.1),
block = 2,
rand_ratio = c(control = 1, treatment = 1),
prop_loss = 0.30,
alternative = "less",
h0 = 0,
Fn = 0.05,
Sn = 0.9,
prob_ha = 0.975,
N_impute = 10,
N_mcmc = 10,
method = "bayes-surv")
#> prob_threshold margin alternative N_treatment N_control N_enrolled N_max
#> 1 0.975 0 less 300 300 600 600
#> post_prob_ha est_final ppp_success stop_futility stop_immediate_success
#> 1 1 -0.1083405 0.5 0 0
#> stop_expected_success trial_success stopping_reason decision_time
#> 1 0 TRUE maximum_sample_size 63.45618
#> accrual_stop_time analysis_ready_time planned_completion_time
#> 1 27.54104 63.45618 63.54104
#> followup_person_time peak_active_followup
#> 1 16488.21 478