The goldilocks package implements the Goldilocks
adaptive sample-size design of Broglio, Connor, and Berry (2014) for
time-to-event and fixed-time binary endpoints. This vignette outlines
the technical details of the design, including notation, the
continuous-time enrollment process, the piecewise-exponential event-time
model, Gamma posterior updating, posterior predictive
probabilities, interim decision rules, final analysis options,
and simulation-based calibration. The package vignettes “Two-arm
randomized trials”, “Bayesian piecewise-exponential designs”, “Bayesian
binary outcome designs”, and “Single-arm designs with a performance
goal” provide more application-focused examples in R.
Consider a trial with maximum sample size \(N_{\max}\), planned endpoint time \(\tau\), and interim sample-size selection analyses after
\[n_1 < n_2 < \cdots < n_L < N_{\max}\]
subjects have been enrolled. The package argument
N_total corresponds to \(N_{\max}\), end_of_study to
\(\tau\), and interim_look
to \((n_1,\ldots,n_L)\).
Let \(Z_i \in \{0,1\}\) denote
treatment assignment for subject \(i\),
matching the package data column treatment: \(Z_i = 1\) for the treatment arm and \(Z_i = 0\) for the control arm. In a
single-arm design, all \(Z_i = 1\) and
there is no concurrent control. The package assumes that randomization
occurs at enrollment; in practice those times can differ, but the
distinction is not represented in the simulation model. We therefore use
enrollment time throughout. Let \(E_i\)
denote enrollment time from first patient in, \(T_i^*\) the true event time from
enrollment, \(C_i\) the administrative
or loss-to-follow-up censoring time, and
\[T_i = \min(T_i^*, C_i), \qquad \delta_i = I(T_i^* \le C_i).\]
At the interim analysis held when \(n_\ell\) subjects have been enrolled, the analysis calendar time is \(E_{n_\ell}\). Subject \(i\)’s current observed follow-up is
\[u_{i\ell} = \max\{0, E_{n_\ell} - E_i\}.\]
For enrolled subjects, the interim data are masked to the information available at this calendar time. If an event has not yet occurred by \(u_{i\ell}\), the subject is treated as censored at \(u_{i\ell}\). Subjects with \(i > n_\ell\) are not yet enrolled and contribute only to the maximum-sample-size prediction.
At each interim analysis the design estimates two predictive probabilities:
The current-sample-size probability is compared first with the
immediate-success threshold \(Q_\ell\)
and then with the expected-success threshold \(S_\ell\). The maximum-sample-size
probability is compared with the futility threshold \(F_\ell\). These correspond to the package
arguments Qn, Sn, and Fn. The
package requires \(Q_\ell \ge S_\ell\);
the default \(Q_\ell = 1\) disables
immediate-success stopping because decisions use strict
inequalities.
The simulation model places the first enrolled subject at time zero. This is a first-patient-in origin, not an earlier protocol-approval, site-activation, or recruitment-opening date. Let \(E_1 = 0\) and let \(E_i\) for \(i > 1\) denote the calendar time of the \(i\)th enrollment measured from first patient in.
Enrollment after the first patient follows a non-homogeneous Poisson process with a piecewise-constant intensity. Write the \(K\) internal enrollment-rate knots as
\[0 < a_1 < a_2 < \cdots < a_K,\]
and define \(a_0 = 0\) and \(a_{K+1} = \infty\). These internal knots
are supplied as lambda_time; zero is implicit and is not
included. There are \(K+1\) positive
rates
\[\boldsymbol{\rho} = (\rho_1,\ldots,\rho_{K+1}),\]
supplied as lambda, with
\[\rho(t) = \rho_j, \qquad a_{j-1} \le t < a_j.\]
This is a convenient right-continuous representation of the
intensity; its value at an isolated knot does not change the Poisson
process. When a realized enrollment time is assigned to a rate interval,
goldilocks uses the survival counting-process convention
\((a_{j-1},a_j]\). An enrollment
exactly at \(a_j\) therefore belongs to
the interval ending there. The first patient at time zero is fixed as
the calendar origin rather than generated by this process.
Consequently, length(lambda) must be exactly
length(lambda_time) + 1. A constant enrollment rate is
represented by lambda_time = NULL and a scalar
lambda. The final rate continues beyond the last knot until
the requested N_total is reached; enrollment()
does not impose a finite recruitment horizon.
The cumulative enrollment intensity is
\[A(t) = \int_0^t \rho(u)\,du = \sum_{j=1}^{K+1} \rho_j\{\min(t,a_j)-a_{j-1}\}_+.\]
To generate the process exactly, draw independent variables \(X_2,\ldots,X_{N_{\max}} \sim \operatorname{Exponential}(1)\) and form
\[Q_i = \sum_{k=2}^{i} X_k.\]
The enrollment times are then obtained through the inverse cumulative intensity,
\[E_1 = 0, \qquad E_i = A^{-1}(Q_i), \quad i=2,\ldots,N_{\max}.\]
More explicitly, if \(A(a_{j-1}) \le Q_i < A(a_j)\), then
\[E_i = a_{j-1} + \frac{Q_i-A(a_{j-1})}{\rho_j}.\]
This time-rescaling construction is exact: after the patient anchored at zero, the number of arrivals in any interval \((s,t]\) is Poisson with mean \(A(t)-A(s)\), and counts over disjoint intervals are independent. Under a constant rate \(\rho\), the successive gaps are independent \(\operatorname{Exponential}(\rho)\) variables and \(E_n \sim \operatorname{Gamma}(n-1,\text{rate}=\rho)\). In particular, \(\operatorname{E}(E_n)=(n-1)/\rho\). The fixed first patient accounts for the \(n-1\), rather than \(n\), random gaps.
This differs from generating Poisson counts in unit-time bins and adding uniform jitter afterward. Such binning is sensitive to the arbitrary width of a time unit and cannot represent a rate change inside a bin. Cumulative- intensity inversion instead preserves the prespecified continuous-time accrual model for integer and fractional change-points alike.
For example,
assigns positive realized enrollment times in \((0,3.5]\) to rate 2, times in \((3.5,9]\) to rate 5, and later times to
rate 8. All rates are enrollments per common time unit.
lambda_time, enrollment times, event times,
cutpoints, generation_cutpoints, and
end_of_study should therefore all use the same unit, such
as days or months.
Although lambda_time, cutpoints, and
generation_cutpoints are all entered as interior
change-points, they operate on different time scales. Enrollment
change-points are trial-calendar times from first patient in. Both
event-time partitions use follow-up from each participant’s enrollment.
Their values and lengths are unrelated unless the scientific design
makes them coincide.
The package does not currently model site activations, site-specific
random rates, pauses, recruitment caps, or uncertainty in the supplied
rates. Those operational features require a richer site-level accrual
model; lambda represents the trial-level rate schedule
assumed for a simulation scenario.
The data-generating and predictive-analysis models are both piecewise exponential, but their partitions may differ. For generation, let
\[0 = g_0 < g_1 < \cdots < g_{K-1}.\]
The interior values \((g_1,\ldots,g_{K-1})\) are supplied through
generation_cutpoints. For treatment value \(z \in \{0,1\}\), the corresponding
hazard_treatment or hazard_control vector
supplies one hazard \(\theta_{zk}\) per
generating interval:
\[h^{\mathrm{gen}}_z(t) = \theta_{zk}, \qquad g_{k-1} \le t < g_k,\]
where \(g_K = \infty\). This is PWEALL’s representation of the continuous generating hazard.
For posterior estimation, predictive imputation, and final piecewise-exponential analysis, let
\[0 = s_0 < s_1 < \cdots < s_{J-1}.\]
The interior cutpoints \((s_1,\ldots,s_{J-1})\) are supplied through
cutpoints; the initial boundary \(s_0 = 0\) is implicit. The analysis model
has one hazard \(\lambda_{zj}\) per
interval. Realized event times are assigned to analysis intervals
using
\[(s_0, s_1], (s_1, s_2], \ldots, (s_{J-1}, \infty).\]
Here \(z = 1\) denotes the treatment arm and \(z = 0\) denotes the control arm. The analysis hazard is
\[h_z(t) = \lambda_{zj}, \qquad s_{j-1} \le t < s_j,\]
where the last interval has no finite upper endpoint. With
cutpoints = NULL, \(J =
1\) and the analysis uses an ordinary exponential model. With
generation_cutpoints = NULL, generation uses one constant
hazard. By default, generation_cutpoints = cutpoints, which
reproduces the historical shared partition; explicitly supplying both
arguments permits model misspecification scenarios without transforming
either partition.
The cumulative hazard and event-time distribution are continuous at
each generating cutpoint, so changing the hazard at the cutpoint itself
does not change generated event times. For observed-data sufficient
statistics, goldilocks follows
Surv(start, stop, event) and survSplit(): an
event recorded exactly at \(s_j\) is
counted in the analysis interval ending at \(s_j\). This explicit rule matters for
rounded or discrete recorded times even though the boundary has
probability zero under a continuous generating model.
The cumulative hazard for treatment value \(z\) at time \(t\) is
\[H_z(t) = \sum_{j=1}^{J} \lambda_{zj} \{ \min(t, s_j) - s_{j-1} \}_+,\]
where \(s_J = \infty\) and \(\{x\}_+ = \max(x,0)\). The corresponding survival and cumulative event probability are
\[S_z(t) = \exp\{-H_z(t)\}, \qquad p_z(t) = 1 - S_z(t).\]
For simulation planning, prop_to_haz() returns the
piecewise hazards implied by event probabilities at prespecified time
points. ppwe() evaluates \(p_z(\tau)\), and haz_to_prop()
applies this transformation to posterior hazard draws.
For observed follow-up \((T_i, \delta_i, Z_i)\), the piecewise-exponential likelihood can be written in terms of interval-specific event counts and exposure times. Define
\[d_{zj} = \sum_i I(Z_i = z)\delta_i I(T_i \in (s_{j-1}, s_j]),\]
and
\[y_{zj} = \sum_i I(Z_i = z) \{ \min(T_i, s_j) - s_{j-1} \}_+ I(T_i > s_{j-1}).\]
Up to factors not involving \(\lambda_{zj}\), the likelihood contribution for treatment value \(z\) is
\[L_z(\boldsymbol{\lambda}_z; \mathcal{D}) \propto \prod_{j=1}^{J} \lambda_{zj}^{d_{zj}} \exp(-\lambda_{zj}y_{zj}),\]
where \(\boldsymbol{\lambda}_z = (\lambda_{z1},\ldots,\lambda_{zJ})^\top\). This sufficient-statistic form is what makes the Gamma posterior update available in closed form.
For treatment arm \(z\), let \(p_z\) be prop_loss and let
\(\tau = \texttt{end\_of\_study}\) be
the planned follow-up duration per subject, measured
from enrollment. The simulator independently draws
\[D_i \mid Z_i=z \sim \operatorname{Exponential}(\eta_z), \qquad \eta_z = -\log(1-p_z)/\tau,\]
independently of event times and enrollment within each arm. Thus
\(\Pr(D_i \leq \tau \mid Z_i=z)=p_z\).
With prop_loss = 0, \(D_i=\infty\) and no dropout random numbers
are drawn. Values must lie in \([0,1)\); a probability of one would require
an infinite exponential hazard and is rejected. A scalar applies the
same dropout distribution to both arms; a vector named
control and treatment supplies separate arm
probabilities.
The complete simulated observation has
\[C_i=\min(D_i,\tau), \qquad T_i=\min(T_i^*,D_i,\tau), \qquad \delta_i=I\{T_i^*\leq\min(D_i,\tau)\}.\]
The loss_to_fu flag is true only if \(D_i<\min(T_i^*,\tau)\). Events before
dropout remain observed. Administrative censoring is not counted as
dropout, and dropout after an observed event does not make that endpoint
missing. Exact ties retain the event or administrative censoring; ties
have probability zero under the continuous model. At an interim calendar
cut, these observations are additionally limited to each enrolled
subject’s available follow-up.
prop_loss describes the dropout distribution,
not the observed fraction censored by dropout. If \(S_z(t)\) is the underlying event-free
survival curve, the probability of observed dropout by the full
follow-up horizon is
\[q_z=\Pr(D_i<T_i^*,D_i<\tau\mid Z_i=z) =\int_0^\tau S_z(t)\eta_z e^{-\eta_z t}\,dt \leq p_z.\]
For a constant event hazard \(\lambda_z\), this reduces to
\[q_z=\frac{\eta_z}{\lambda_z+\eta_z} \{1-e^{-(\lambda_z+\eta_z)\tau}\}.\]
For example, with 30% event probability by 12 months and
prop_loss = 0.05, the dropout hazard is \(-\log(0.95)/12\) and the expected observed
dropout proportion is about 4.21%. The realized count varies across
simulated trials; five losses are not forced in a 100-subject trial.
Subjects censored by dropout still contribute their observed event-free
follow-up to survival analysis. Equal dropout distributions in arms with
different event hazards can yield different observed dropout
proportions. The fraction observed at an interim look also depends on
enrollment and available follow-up.
To retain an externally specified probability \(q\) at reference time \(t_0\) (for example, 5% annually), supply
\(p=1-(1-q)^{\tau/t_0}\) at the package
horizon. Changing end_of_study while holding
prop_loss fixed changes the implied dropout hazard. All
event, dropout, enrollment, and administrative times must use the same
unit. Treatment discontinuation is not separately modeled: it is not
loss to follow-up when endpoint collection continues.
This mechanism replaces the previous fixed-count selection with
uniform censoring before each selected subject’s potential event or
administrative time. That previous censoring depended on the latent
event time. Positive prop_loss values now change seeded
results and operating characteristics; design simulations should be
rerun. Zero-dropout simulations are unchanged.
For each treatment value \(z\) and
interval \(j\), goldilocks
assumes an independent Gamma prior
\[\lambda_{zj} \sim \operatorname{Gamma}(\alpha_{0zj}, \beta_{0zj}),\]
where \(\alpha_{0zj}\) is the shape
and \(\beta_{0zj}\) is the rate for arm
\(z\) and interval \(j\). This follows the
stats::rgamma() shape-rate parameterization. The
specification prior_surv = c(alpha0, beta0) applies one
shape-rate pair to every arm and interval. Alternatively, a two-row
matrix specifies interval-specific shapes in row 1 and rates in row 2,
with intervals in chronological order, and applies them to both arms.
Independent arm- specific priors are supplied as a list named
control and treatment; each element may be a
length-two vector or a two-row interval-specific matrix. Both arms must
be specified, and no borrowing occurs between them.
prior_surv_final accepts the same specifications and
defaults to prior_surv; priors may therefore differ by
analysis stage, arm, and interval. For
method = "bayes-surv",
prior_surv_final is used during interim
calculations as well as at the actual final analysis:
| Calculation | Prior used |
|---|---|
| Generate outstanding outcomes at interim, for enrolled and future participants | prior_surv |
| Test each hypothetical completed trial at the current or maximum sample size | prior_surv_final |
Impute missing outcomes at final analysis, if
imputed_final = TRUE |
prior_surv_final |
| Analyze the actual final data | prior_surv_final |
An informative predictive prior can bring in external evidence while
a separate weak analysis prior defines the success criterion.
Both must be specified explicitly for this separation: omitting
prior_surv_final makes it equal to prior_surv,
including when prior_surv is informative. These
roles also apply to evaluate_interim(), which performs the
two interim calculations. See the worked
example.
The predictive prior can still influence the stopping decision and
selected sample size. Calibrate the design with both priors fixed to
their intended values. This table applies to Bayesian survival: Bayesian
binary completed-data analyses use prior_bin, and
frequentist completed-data tests have no analysis prior.
At an analysis, let \(d_{zj}\) be the number of observed events for treatment value \(z\), interval \(j\), and let \(y_{zj}\) be the total observed exposure time for that treatment value and interval. Gamma-exponential conjugacy gives
\[\lambda_{zj} \mid \mathcal{D} \sim \operatorname{Gamma}(\alpha_{0zj} + d_{zj}, \beta_{0zj} + y_{zj}).\]
The package obtains \((d_{zj},
y_{zj})\) by splitting each subject’s observed follow-up over the
cut-point intervals. Posterior draws are generated independently for
each treatment group and interval. In early interim analyses, later
piecewise intervals may have no exposure. The
empty_interval argument controls the policy for these
intervals:
empty_interval = "prior" is the default. It leaves the
interval with \(d_{zj} = 0\) and \(y_{zj} = 0\), so the posterior for that
interval is exactly the specified Gamma prior. Interval-specific priors
should therefore be checked by prior-predictive simulation when little
late follow-up is expected.empty_interval = "propagate" is an explicit legacy
heuristic. It propagates exposure and event counts from the nearest
non-empty interval within the same treatment group and emits a warning.
This should not be interpreted as observed evidence about the empty
interval. Set this option explicitly only to reproduce or
sensitivity-check historical analyses.empty_interval = "error" stops the analysis when any
treatment-arm interval has no exposed subjects.The posterior density factorizes as
\[\pi(\boldsymbol{\lambda} \mid \mathcal{D}) = \prod_z \prod_{j=1}^{J} \pi(\lambda_{zj} \mid d_{zj}, y_{zj}),\]
where each marginal factor is the Gamma distribution above. Posterior predictive calculations integrate over this density rather than conditioning on a single plug-in hazard estimate.
At an interim analysis, subjects can be separated into three sets:
The first set contributes observed events and exposure to the posterior. The second and third sets require prediction.
For an enrolled subject who is event-free through time \(u\), a future event time is drawn from the conditional piecewise-exponential distribution
\[\Pr(T \le t \mid T > u) = \frac{F(t) - F(u)}{1 - F(u)}, \qquad t > u,\]
where \(F(t) = 1 - S(t)\). Equivalently, if \(U \sim \operatorname{Uniform}(0,1)\), then
\[T = F^{-1}\{F(u) + U[1 - F(u)]\}.\]
pwe_impute() samples from this conditional distribution.
For future participants in the maximum-sample-size calculation,
pwe_sim() draws unconditional event times from the same
piecewise-exponential model. The number of future participants is \(N_{\max}-n_\ell\); their individual future
enrollment times are not needed for this predictive calculation.
Let \(\mathcal{D}_{\ell}^{\mathrm{obs}}\) denote the data observed at look \(\ell\), and let \(\mathcal{D}^{\mathrm{mis}}\) denote unobserved event times and future censoring indicators. The posterior predictive density is
\[p(\mathcal{D}^{\mathrm{mis}} \mid \mathcal{D}_{\ell}^{\mathrm{obs}}) = \int p(\mathcal{D}^{\mathrm{mis}} \mid \boldsymbol{\lambda}) \pi(\boldsymbol{\lambda} \mid \mathcal{D}_{\ell}^{\mathrm{obs}}) d\boldsymbol{\lambda}.\]
The package approximates this integral by Monte Carlo simulation. Each replicate draws \(\boldsymbol{\lambda}\) from its interim posterior, completes the unobserved outcomes conditional on those hazards, and applies the prespecified analysis. Treatment assignments remain fixed. Bayesian survival, log-rank, Cox, and RMST analyses use completed follow-up and event outcomes; fixed-horizon binary analyses use completed event counts and denominators by arm, which are sufficient statistics for the risk-difference and beta-binomial methods.
At interim look \(\ell\), the package first estimates the posterior of the hazard parameters from the currently observable data. It then uses Monte Carlo integration to approximate \(P_{n_\ell}\) and \(P_{\max,\ell}\).
Let \(\psi(\mathcal{D})\) be the final success indicator for a completed analysis dataset:
\[\psi(\mathcal{D}) = I\{Q(\mathcal{D}) > c\},\]
where \(Q(\mathcal{D})\) is the
final analysis quantity and \(c\) is
the success threshold. In package notation, \(c\) is set by prob_ha. The
final analysis quantity \(Q(\mathcal{D})\) depends on the analysis
method:
| Design setting | method |
\(Q(\mathcal{D})\) | Supported alternatives |
|---|---|---|---|
| Two-arm randomized trial | logrank |
\(1-p(\mathcal{D})\), where \(p(\mathcal{D})\) is the traditional log-rank test P-value, with one-sided variants defined in Section 7.1 | "less", "greater",
"two.sided" |
| Two-arm randomized trial | rmst |
\(1-p(\mathcal{D})\) for a Wald
test of the treatment-control RMST difference through
rmst_tau |
"less", "greater",
"two.sided" |
| Two-arm randomized trial | cox |
\(1-p(\mathcal{D})\), where \(p(\mathcal{D})\) is the traditional Wald-test P-value, with one-sided variants defined in Section 7.1 | "less", "greater",
"two.sided" |
| Two-arm randomized trial | riskdiff-wald |
\(1-p(\mathcal{D})\), where \(p(\mathcal{D})\) is the Wald-test P-value for the treatment-control event-risk difference | "less", "greater",
"two.sided" |
| Two-arm randomized trial | riskdiff-fm |
\(1-p(\mathcal{D})\), where \(p(\mathcal{D})\) is the Farrington-Manning score-test P-value for the treatment-control event-risk difference | "less", "greater",
"two.sided" |
| Two-arm randomized trial | bayes-surv |
\(\Pr(\Delta < h_0 \mid \mathcal{D})\) or \(\Pr(\Delta > h_0 \mid \mathcal{D})\) | "less", "greater" |
| Single-arm trial | bayes-surv |
\(\Pr(p_1(\tau) < h_0 \mid \mathcal{D})\) or \(\Pr(p_1(\tau) > h_0 \mid \mathcal{D})\) | "less", "greater" |
| Two-arm randomized trial | bayes-bin |
\(\Pr(\Delta_{\mathrm{bin}} < h_0 \mid \mathcal{D})\) or \(\Pr(\Delta_{\mathrm{bin}} > h_0 \mid \mathcal{D})\) | "less", "greater" |
| Single-arm trial | bayes-bin |
\(\Pr(\pi_1 < h_0 \mid \mathcal{D})\) or \(\Pr(\pi_1 > h_0 \mid \mathcal{D})\) | "less", "greater" |
For frequentist analyses, prob_ha is therefore a
transformed P-value threshold. For example, prob_ha = 0.975
corresponds to a one-sided \(\alpha =
0.025\) rule. The value should be chosen during design
calibration to control the desired type I error rate across relevant
null scenarios.
The current-sample-size predictive probability \(P_{n_\ell}\) is estimated by:
For Bayesian survival, step 1 uses prior_surv and step 3
updates prior_surv_final with the completed events and
exposure. The posterior used to generate outcomes is not substituted for
the completed-data analysis prior. The maximum-sample calculation uses
this same separation of priors.
For example, write \(\pi_{\mathrm{pred}}\) for
prior_surv and \(\pi_{\mathrm{ana}}\) for
prior_surv_final. For alternative = "less",
the predictive target is
\[P_{n_\ell} = \operatorname{E}_{\mathrm{pred}}\left[ I\left\{ \Pr_{\mathrm{ana}}\left(\Delta < h_0 \mid \mathcal{D}^{\mathrm{obs}}_\ell,\mathcal{D}^{\mathrm{mis}}\right) > c \right\} \mid \mathcal{D}^{\mathrm{obs}}_\ell \right].\]
The outer expectation generates missing outcomes from the posterior
predictive distribution under \(\pi_{\mathrm{pred}}\). The inner
probability analyzes each completed dataset under \(\pi_{\mathrm{ana}}\), with \(c=\) prob_ha. In a single-arm
design, replace \(\Delta\) with the
treatment event probability. Thus the hypothetical final success test
and the actual final success test use the same analysis prior, even when
the predictive prior differs.
Formally,
\[P_{n_\ell} = \operatorname{E}\{ \psi(\mathcal{D}_{n_\ell}^{\mathrm{comp}}) \mid \mathcal{D}_{\ell}^{\mathrm{obs}} \},\]
where \(\mathcal{D}_{n_\ell}^{\mathrm{comp}}\) is the completed dataset formed from the \(n_\ell\) enrolled subjects after imputing their remaining follow-up. Equivalently,
\[P_{n_\ell} = \int \psi(\mathcal{D}_{n_\ell}^{\mathrm{obs}}, \mathcal{D}_{n_\ell}^{\mathrm{mis}}) p(\mathcal{D}_{n_\ell}^{\mathrm{mis}} \mid \mathcal{D}_{\ell}^{\mathrm{obs}}) d\mathcal{D}_{n_\ell}^{\mathrm{mis}}.\]
Repeating the four-step procedure above for Monte Carlo replicate
\(m = 1,\ldots,M\), where \(M\) is set by N_impute,
gives
\[\widehat{P}_{n_\ell} = \frac{1}{M}\sum_{m=1}^{M} I\{\text{success in replicate } m\}.\]
For Bayesian completed-data analyses that use N_mcmc
posterior draws, a replicate is counted as successful when its estimated
posterior success probability exceeds prob_ha.
Deterministic quadrature, approximation, and frequentist analyses use
the same strict point-estimate comparison. Exact one-sided binomial
bounds for posterior Monte Carlo estimates are retained as diagnostics
but do not change this classification.
For the fixed-horizon binary methods, a completed replicate is
summarized by \((x_0,n_0,x_1,n_1)\) in
a two-arm design, or \((x_1,n_1)\) in a
single-arm design, where \(x_z\) and
\(n_z\) are the event count and
denominator in arm \(z\). There is no
loss of statistical information for the risk-difference or beta-binomial
analysis because individual event times are not used once endpoint
status is complete. With bin_method = "mc", each predictive
replicate receives an independent set of N_mcmc
beta-posterior draws, thereby preserving the two sources of Monte Carlo
variation.
The upper decisions are evaluated in order. If
\[\widehat{P}_{n_\ell} > Q_\ell,\]
the trial stops and immediately declares official success. Otherwise, if
\[\widehat{P}_{n_\ell} > S_\ell,\]
accrual is stopped for expected success. Enrolled subjects are still followed to the planned final analysis time.
The decision trace also reports the Monte Carlo standard error and
one-sided exact bounds for \(\widehat{P}_{n_\ell}\) at confidence level
mc_conf_level. These quantify finite-imputation uncertainty
and are diagnostic only.
The maximum-sample-size predictive probability \(P_{\max,\ell}\) is estimated similarly, except that the completed trial includes both currently enrolled subjects and future subjects required to reach \(N_{\max}\). For each replicate, event times are imputed for the future subjects, the completed dataset is analyzed, and success is recorded:
\[P_{\max,\ell} = \operatorname{E}\{ \psi(\mathcal{D}_{N_{\max}}^{\mathrm{comp}}) \mid \mathcal{D}_{\ell}^{\mathrm{obs}} \}.\]
\[\widehat{P}_{\max,\ell} = \frac{1}{M}\sum_{m=1}^{M} I\{\text{success at } N_{\max} \text{ in replicate } m\}.\]
If neither upper decision is crossed and
\[\widehat{P}_{\max,\ell} < F_\ell,\]
the trial stops for binding futility and declares official failure. Otherwise, accrual continues to the next interim look.
The corresponding exact upper bound is reported in the trace as a diagnostic; it does not replace \(\widehat{P}_{\max,\ell}\) in the stopping rule.
Thus the interim action at look \(\ell\) can be represented as
\[A_\ell = \begin{cases} \text{stop and declare immediate success}, & \widehat{P}_{n_\ell} > Q_\ell,\\ \text{stop accrual for expected success}, & S_\ell < \widehat{P}_{n_\ell} \le Q_\ell,\\ \text{stop and declare binding futility}, & \widehat{P}_{n_\ell} \le S_\ell \text{ and } \widehat{P}_{\max,\ell} < F_\ell,\\ \text{continue accrual}, & \text{otherwise}. \end{cases}\]
The first look producing a non-continuation decision defines the adaptive stopping look. Because \(Q_\ell \ge S_\ell\), the immediate-success region is contained in the upper stopping region, so this can be written as
\[L^* = \inf\{\ell : \widehat{P}_{n_\ell} > S_\ell \text{ or } \widehat{P}_{\max,\ell} < F_\ell\},\]
with \(L^* = L + 1\) if no interim stopping condition is met and the design continues to \(N_{\max}\).
After an expected-success stop or completion of enrollment, the final
analysis is conducted when the relevant follow-up has completed for the
enrolled cohort, subject to the handling of loss to follow-up described
below. Immediate success and binding futility are terminal official
decisions at the interim look and do not require a later analysis to
determine trial_success. The final rule below also supplies
the binary success indicator used inside the predictive probability
calculations.
For method = "logrank", success is based on a log-rank
test. For method = "cox", success is based on the Wald test
from a Cox proportional hazards regression. For
method = "rmst", success uses a Wald test of the
treatment-control RMST difference through rmst_tau. For a
treatment-control difference in binary event risks at
end_of_study, method = "riskdiff-wald" uses a
Wald test and method = "riskdiff-fm" uses a
Farrington-Manning score test. For these methods,
goldilocks stores \(1-p\)
in post_prob_ha; this is not a posterior probability, but
it puts frequentist and Bayesian rules on a common “larger is stronger
evidence” scale. For example, a one-sided test at \(\alpha = 0.025\) corresponds to
prob_ha = 0.975.
For backward compatibility, method = "riskdiff" is
accepted as an alias for "riskdiff-wald" and produces a
warning. Results identify the analysis as
"riskdiff-wald".
For the log-rank option, let \(Z_{\mathrm{LR}}\) denote the signed
log-rank statistic, with positive values corresponding to excess events
in the control arm under the package convention. Let \(p_{\mathrm{LR}}\) denote the traditional
two-sided log-rank test P-value. The log-rank method supports only
h0 = 0, denoting equal survival distributions; a nonzero
margin is rejected rather than silently ignored. For the Cox option, let
\(\widehat{\eta}\) be the estimated log
hazard ratio for treatment versus control. For Cox analysis,
h0 is on the log-hazard-ratio scale, so the package
uses
\[Z_{\mathrm{Cox}} = \frac{\widehat{\eta} - h_0} {\operatorname{se}(\widehat{\eta})}.\]
When h0 = 0, this is the usual hazard-ratio-equals-1
null. A non-inferiority margin specified as a hazard ratio can be
supplied as h0 = log(margin). Here, lower treatment hazard
corresponds to \(Z_{\mathrm{Cox}} <
0\). Let \(p_{\mathrm{Cox}}\)
denote the two-sided Wald-test P-value relative to h0. The
package uses the following method-specific definitions of \(Q(\mathcal{D})\):
For method = "rmst", let \(\tau_R\) denote rmst_tau, a
prespecified restriction time in \((0,\tau]\) that defaults to
end_of_study. The effect is
\[\widehat\Delta_R = \int_0^{\tau_R}\widehat S_1(t)\,dt - \int_0^{\tau_R}\widehat S_0(t)\,dt.\]
The curves are Kaplan-Meier estimates. For arm \(z\), the Greenwood plug-in variance is
\[U_z = \sum_{j:t_{zj}<\tau_R} \left\{\int_{t_{zj}}^{\tau_R}\widehat S_z(t)\,dt\right\}^{2} \frac{d_{zj}}{Y_{zj}(Y_{zj}-d_{zj})},\]
where \(Y_{zj}\) is the risk set
immediately before event time \(t_{zj}\) and \(d_{zj}\) is the number of events there. A
terminal jump to zero contributes zero tail area and zero variance term.
The test statistic is \(Z_R=(\widehat\Delta_R-h_0)/\sqrt{U_0+U_1}\).
Positive effects mean longer time without the event on treatment. Both
the estimated effect and h0 use time units; h0
must lie in \([-\tau_R,\tau_R]\). For
an adverse event, superiority uses alternative = "greater",
and non-inferiority allowing a loss of \(m\) time units uses the same alternative
with h0 = -m.
The horizon is identical across arms, looks, and completed
replicates; it is never selected from the observed follow-up. Positive
estimated survival at an arm’s last follow-up before \(\tau_R\) makes the analysis non-estimable.
A curve reaching zero before that horizon is allowed. The test requires
positive total variance, although one arm may have zero variance. RMST
inference does not require proportional hazards, but predictive
imputation still depends on the piecewise-exponential model. Reducing
rmst_tau does not reduce end_of_study or
change the calendar-time calculations.
For the risk-difference options, let \(\widehat p_1\) and \(\widehat p_0\) be the observed event proportions in the treatment and control arms, with sample sizes \(n_1\) and \(n_0\). Both report the estimated effect
\[\widehat\Delta = \widehat p_1 - \widehat p_0,\]
and test \(H_0: p_1-p_0=h_0\). The Wald method uses the unpooled plug-in variance
\[U_{\Delta} = \frac{\widehat p_1(1-\widehat p_1)}{n_1} + \frac{\widehat p_0(1-\widehat p_0)}{n_0}.\]
The complete-data Wald statistic is
\[Z_{\mathrm{Wald}} = \frac{\widehat\Delta-h_0}{\sqrt{U_{\Delta}}}.\]
For riskdiff-fm, let \(\widetilde p_0\) and \(\widetilde p_1\) be the joint binomial
maximum likelihood estimates constrained so that \(\widetilde p_1-\widetilde p_0=h_0\). The
package obtains these estimates by maximizing the one-dimensional
likelihood over
\[\max(0,-h_0) \leq \widetilde p_0 \leq \min(1,1-h_0),\]
with \(\widetilde p_1=\widetilde p_0+h_0\). The Farrington-Manning statistic is
\[Z_{\mathrm{FM}} = \frac{\widehat\Delta-h_0} {\sqrt{\widetilde p_1(1-\widetilde p_1)/n_1 + \widetilde p_0(1-\widetilde p_0)/n_0}}.\]
No continuity correction is applied. If the constrained variance is zero, the statistic is defined as zero when \(\widehat\Delta=h_0\), positive infinity when \(\widehat\Delta>h_0\), and negative infinity otherwise. Consequently, equal-arm all-zero and all-one tables under \(h_0=0\) give a neutral one-sided result rather than an error.
| Method | Alternative | \(Q(\mathcal{D})\) |
|---|---|---|
logrank |
"less" |
\(\Phi(Z_{\mathrm{LR}})\) |
logrank |
"greater" |
\(1 - \Phi(Z_{\mathrm{LR}})\) |
logrank |
"two.sided" |
\(1 - p_{\mathrm{LR}}\) |
rmst |
"less" |
\(1-\Phi(Z_R)\) |
rmst |
"greater" |
\(\Phi(Z_R)\) |
rmst |
"two.sided" |
\(1-2\Phi(-|Z_R|)\) |
cox |
"less" |
\(1 - \Phi(Z_{\mathrm{Cox}})\) |
cox |
"greater" |
\(\Phi(Z_{\mathrm{Cox}})\) |
cox |
"two.sided" |
\(1 - p_{\mathrm{Cox}}\) |
riskdiff-wald |
"less" |
\(1 - \Phi(Z_{\mathrm{Wald}})\) |
riskdiff-wald |
"greater" |
\(\Phi(Z_{\mathrm{Wald}})\) |
riskdiff-wald |
"two.sided" |
\(1 - 2\Phi(-|Z_{\mathrm{Wald}}|)\) |
riskdiff-fm |
"less" |
\(1 - \Phi(Z_{\mathrm{FM}})\) |
riskdiff-fm |
"greater" |
\(\Phi(Z_{\mathrm{FM}})\) |
riskdiff-fm |
"two.sided" |
\(1 - 2\Phi(-|Z_{\mathrm{FM}}|)\) |
The one-sided directions differ between the log-rank rows and the model-based rows because of the sign convention of the package’s log-rank statistic.
The risk-difference analysis discards event-time information and
requires complete binary endpoint status. est_final reports
\(\widehat\Delta\).
When a Cox, RMST, or riskdiff-wald final analysis uses
multiple imputation, the analysis is applied separately to each
completed dataset. Let \(\widehat{\theta}_m\) and \(U_m\) be the scalar effect estimate and its
estimated variance from imputation \(m =
1,\ldots,M\). For Cox regression \(\widehat{\theta}_m\) is the log hazard
ratio; for risk difference it is \(\widehat\Delta_m\). For RMST it is \(\widehat\Delta_{R,m}\), with \(U_m\) the sum of the arm-specific Greenwood
variances. Rubin’s scalar pooling rules give
\[\bar{\theta} = \frac{1}{M}\sum_{m=1}^{M}\widehat{\theta}_m, \qquad \bar{U} = \frac{1}{M}\sum_{m=1}^{M}U_m,\]
\[B = \frac{1}{M-1}\sum_{m=1}^{M} (\widehat{\theta}_m - \bar{\theta})^2, \qquad T = \bar{U} + \left(1 + \frac{1}{M}\right)B.\]
The pooled Wald statistic is \((\bar{\theta} - h_0) / \sqrt{T}\). Its P-value uses a \(t\) reference distribution with Rubin’s large-sample degrees of freedom
\[\nu = (M-1)\left(1 + \frac{1}{r}\right)^2, \qquad r = \frac{(1 + 1/M)B}{\bar{U}}.\]
When \(B = 0\) and \(\bar U > 0\), \(\nu = \infty\) and the reference
distribution reduces to the standard normal distribution. If \(\bar U = 0\) and \(B > 0\), the package uses \(\nu = M-1\). If both variance components
are zero, the pooled analysis is non-estimable and raises an error. At
least two imputations and positive total variance are required. The
returned est_final is \(\bar{\theta}\), while
post_prob_ha is \(1-p\)
from this pooled test with the direction determined by
alternative.
If final outcomes are complete, the selected test is applied directly
with either imputation flag. Genuine final imputation is unsupported for
riskdiff-fm because no validated FM pooling rule is
implemented; the package does not substitute a Wald test. Simulations
combining FM with imputed_final = TRUE require zero
prop_loss in both arms.
For method = "bayes-surv", the analysis posterior
updates prior_surv_final with the dataset’s observed or
imputed events and exposure. This applies both to hypothetical completed
trials tested inside an interim prediction and to the actual final
analysis. Posterior hazard draws are mapped to cumulative event
probabilities at \(\tau\). In a two-arm
design the treatment effect is
\[\Delta = p_1(\tau) - p_0(\tau),\]
where \(p_1(\tau)\) is the treatment-arm event probability and \(p_0(\tau)\) is the control-arm event probability. The effect is on the event scale, not the survival scale. For an adverse event, benefit usually means \(\Delta < 0\).
Because \(p_a(\tau) = 1 - \exp\{-H_a(\tau)\}\), posterior draws of \(\Delta\) are obtained by transforming posterior draws of \(\boldsymbol{\lambda}_1\) and \(\boldsymbol{\lambda}_0\):
\[\Delta^{(b)} = \left[1 - \exp\{-H_1^{(b)}(\tau)\}\right] - \left[1 - \exp\{-H_0^{(b)}(\tau)\}\right], \qquad b = 1,\ldots,B.\]
The fixed analysis-interval widths span time zero through
end_of_study; they do not shorten to the maximum follow-up
observed at an interim or final data cut. Observed events and
person-time determine the Gamma posterior in each interval. Posterior
hazards are transformed to \(H_a(\tau)\) and then to the event
probability at the prespecified endpoint horizon.
The Monte Carlo estimate of the posterior probability for
alternative = "less" is
\[\widehat{\Pr}(\Delta < h_0 \mid \mathcal{D}) = \frac{1}{B}\sum_{b=1}^{B} I(\Delta^{(b)} < h_0),\]
where \(B\) is set by
N_mcmc.
With alternative = "less", success is declared when
\[\Pr(\Delta < h_0 \mid \mathcal{D}) > \texttt{prob\_ha}.\]
With alternative = "greater", success is declared
when
\[\Pr(\Delta > h_0 \mid \mathcal{D}) > \texttt{prob\_ha}.\]
The Bayesian final test is one-sided in the package;
alternative = "two.sided" is not supported.
In a single-arm design there is no \(p_0(\tau)\). The estimand becomes \(p_1(\tau)\), and \(h_0\) is an external benchmark event
probability. In clinical-trial terminology this benchmark is often
called a performance goal (PG) or objective performance criterion (OPC).
Consequently, single-arm survival designs in goldilocks
require method = "bayes-surv"; complete binary single-arm
designs can use method = "bayes-bin".
For method = "bayes-bin", each analysis dataset is
reduced to the binary indicator of whether the endpoint has occurred by
\(\tau\). Subjects with right-censored
follow-up before \(\tau\) must be
imputed or excluded before this final test is applied, as described
below.
Let \(x_z\) be the number of events
and \(n_z\) the number of subjects in
treatment group \(z\). With
prior_bin = c(a, b), the event probability in arm \(z\) has posterior distribution
\[\pi_z \mid \mathcal{D} \sim \operatorname{Beta}(a + x_z, b + n_z - x_z).\]
In a two-arm design, the binary treatment effect is
\[\Delta_{\mathrm{bin}} = \pi_1 - \pi_0,\]
the treatment-arm event probability minus the control-arm event
probability. For an adverse binary event, benefit usually means \(\Delta_{\mathrm{bin}} < 0\). With
alternative = "less", success is declared when
\[\Pr(\Delta_{\mathrm{bin}} < h_0 \mid \mathcal{D}) > \texttt{prob\_ha}.\]
With alternative = "greater", success is declared
when
\[\Pr(\Delta_{\mathrm{bin}} > h_0 \mid \mathcal{D}) > \texttt{prob\_ha}.\]
In a single-arm design, the estimand is \(\pi_1\) and h0 is the external
benchmark event probability. Thus, alternative = "less"
declares success when
\[\Pr(\pi_1 < h_0 \mid \mathcal{D}) > \texttt{prob\_ha}.\]
The posterior probability can be computed in three ways. With
bin_method = "mc", the package draws from the beta
posterior directly. With bin_method = "normal", it
approximates the posterior event probability or treatment-control
difference by a normal distribution with matching mean and variance.
With bin_method = "quadrature", it evaluates the Beta CDF
directly for a single arm and uses numerical integration for the two-arm
posterior difference. The argument N_mcmc controls the
number of Monte Carlo beta draws only when
bin_method = "mc".
With sparse events or non-events and posterior event probabilities
near 0 or 1, the normal approximation can misrepresent tail
probabilities and change success or interim stopping decisions.
Increasing N_mcmc does not correct this error. Use
bin_method = "quadrature" or sufficiently precise Monte
Carlo Beta draws when the approximation is unsuitable.
The completed-data calculation depends on \((x_z,n_z)\) directly. Participant- level
data are reduced to these sufficient statistics after complete endpoint
ascertainment has been verified. Normal-approximation, quadrature, and
risk- difference results are deterministic conditional on these counts.
With bin_method = "mc", posterior simulation is repeated
independently for every predictive replicate.
Interim predictions impute outcomes that are not yet known. At the
final analysis, imputed_final controls whether subjects
lost to follow-up are also imputed.
If no final outcomes require imputation, the selected complete-data
test is used directly with either flag. Otherwise, with
imputed_final = TRUE, Bayesian methods
(method = "bayes-surv" or
method = "bayes-bin") analyze each imputed completed
dataset and average the resulting posterior summaries. Cox regression,
RMST, and riskdiff-wald instead pool completed-data scalar
estimates and variances using Rubin’s rules as described above;
N_impute must be at least two. Genuine final imputation is
unsupported for riskdiff-fm. Imputed final analyses remain
unavailable for method = "logrank" because no pooling rule
is implemented for that test.
If imputed_final = FALSE, the final analysis uses
observed right-censored data for methods that can handle censoring
(logrank, cox, rmst, and
bayes-surv). For riskdiff-wald,
riskdiff-fm, and bayes-bin, lost-to-follow-up
subjects are excluded because these methods require complete binary
outcomes and have no mechanism for right-censored observations. Rubin
pooling applies to imputed Cox, RMST, and riskdiff-wald
final analyses; it does not alter the interim posterior-predictive
calculation, where each simulated completed trial is tested separately
before the success indicators are averaged.
The independent dropout mechanism in Section 3.1 supports right-censored survival inference within each arm. It does not imply unbiased complete-case binary inference: early events can be ascertained before dropout, while later endpoint outcomes can be missing. Excluding the latter can overestimate the fixed-time event probability and distort treatment comparisons. Binary designs with dropout should assess final imputation under a suitable event-time model and sensitivity to that model. Designs where dropout depends on prognosis require sensitivity analyses outside the default independent mechanism.
A Goldilocks design is calibrated by simulation. A single simulated trial describes one possible path; the design is characterized by repeated simulation over clinically relevant scenarios.
For a candidate design, sim_trials() generates repeated
trials and summarise_sims() estimates:
Let \(R = 1,\ldots,R_{\max}\) index simulated trials under a scenario \(\theta\), where \(\theta\) denotes the data-generating parameters such as control hazard, treatment hazard, accrual rate, loss-to-follow-up rate, and follow-up duration. The trial-level random variables are:
| Symbol | Meaning |
|---|---|
| \(N_R\) | enrolled sample size in simulated trial \(R\) |
| \(I_R\) | indicator that trial \(R\) declared immediate success |
| \(E_R\) | indicator that trial \(R\) stopped accrual for expected success |
| \(F_R\) | indicator that trial \(R\) stopped for futility |
| \(Z_R\) | official success indicator in trial \(R\) |
Let \(\Theta_0\) denote the null parameter space, i.e. the set of data-generating scenarios in which the treatment does not satisfy the alternative hypothesis. For a two-arm superiority trial this includes scenarios with no beneficial treatment effect; in practice, it should be explored across plausible nuisance parameters such as control event rates and accrual rates. The main operating characteristics are
\[\operatorname{Power}(\theta) = \Pr_\theta(Z_R = 1),\]
\[\operatorname{Type\ I\ error}(\theta_0) = \Pr_{\theta_0}(Z_R = 1), \qquad \theta_0 \in \Theta_0,\]
\[\Pr_\theta(\text{declare immediate success}) = \Pr_\theta(I_R = 1),\]
\[\Pr_\theta(\text{stop for expected success}) = \Pr_\theta(E_R = 1),\]
\[\Pr_\theta(\text{stop for futility}) = \Pr_\theta(F_R = 1),\]
and
\[\operatorname{E}_\theta(N_R), \qquad \operatorname{Var}_\theta(N_R).\]
The stop_and_fail summary estimates
\[\Pr_\theta(E_R = 1, Z_R = 0),\]
which is the probability that accrual stops for expected success but the final analysis does not meet the success criterion.
One simulation specification is:
out <- sim_trials(
hazard_treatment = ht,
hazard_control = hc,
cutpoints = cutpoints,
N_total = N_total,
lambda = lambda,
lambda_time = lambda_time,
interim_look = interim_look,
end_of_study = end_of_study,
prior_surv = prior_surv,
Fn = Fn,
Sn = Sn,
Qn = Qn,
prob_ha = prob_ha,
N_impute = N_impute,
N_mcmc = N_mcmc,
N_trials = N_trials,
method = method,
seed = 12345)
summarise_sims(
out,
max_mcse = c(power = 0.005, stop_futility = 0.01, mean_N = 1)
)summarise_sims() reports a Monte Carlo standard error
and 95% Monte Carlo confidence interval for each probability and for
mean sample size. Wilson intervals are used for probabilities so that
zero or one observed outcome does not produce a misleading zero-width
interval; mean sample size uses a t interval. These quantify
repeated-simulation error under fixed design and data-generating
assumptions. They are not clinical confidence intervals for a treatment
effect and do not include uncertainty about the assumed outcome,
accrual, or missing-data models. Requested, analyzed, failed, and used
counts make the denominator explicit. Failed simulations are reported
separately and are not treated as unsuccessful clinical trials. The
optional named max_mcse targets produce a warning when the
achieved Monte Carlo precision is too weak for the intended
comparison.
The simulation plots address three complementary statistical questions:
plot_sim_ocs() compares official success,
immediate-success and other stopping probabilities, and mean sample size
across data-generating scenarios.plot_sim_stopping() expands one scenario into marginal,
conditional, or cumulative stopping summaries, or a count-based
flowchart through successive looks.plot_sim_decisions() examines the joint interim
predictive probabilities and the decision thresholds at each look.For operating-characteristic curves, first attach a numeric effect scale to the scenario summary. The package does not infer this automatically because the appropriate scale may be a hazard ratio, risk difference, RMST difference, survival probability, or event probability depending on the analysis. Match values by scenario name because the summary can reorder the input scenarios:
scenario_oc <- summarise_sims(list(
"null" = null_sims,
"moderate" = moderate_sims,
"target" = target_sims
))
effect_by_scenario <- c(null = 0, moderate = -0.10, target = -0.20)
scenario_oc$true_effect <- unname(effect_by_scenario[scenario_oc$scenario])
plot_sim_ocs(
scenario_oc,
effect = "true_effect",
xlab = "True treatment-control event-probability difference"
)
plot_sim_stopping(target_sims)Decision maps require the optional simulation traces:
target_sims_traced <- update(target_sims, return_trace = TRUE)
plot_sim_stopping(target_sims_traced, type = "flowchart")
plot_sim_decisions(target_sims_traced)Retaining interim histories does not change the simulated trials, but it requires additional storage. The recorded sample sizes allow conditional, cumulative, and flowchart displays to include looks reached without a stopping decision. Detailed histories are therefore usually most useful for selected scenarios after a broad operating-characteristic grid has been screened.
Broglio et al. emphasize that type I error for this class of adaptive design should be examined across the null space, not only at one convenient null scenario. For time-to-event endpoints, the relevant null space includes plausible control event rates and accrual rates. Accrual rate is especially important because rapid enrollment can leave little endpoint information available at interim looks, increasing the uncertainty in both \(\widehat{P}_{n_\ell}\) and \(\widehat{P}_{\max,\ell}\). The follow-up period after accrual stops also affects operating characteristics because it determines how much additional information is observed before the final analysis.
The Monte Carlo sizes N_impute, N_mcmc, and
N_trials should be chosen so that simulation error is small
relative to the design decision being made. goldilocks
reports the estimate, Monte Carlo standard error, exact bounds, number
of draws, and stopping reason in the interim history. Decisions use
strict comparisons of the point estimates with their thresholds; the
bounds quantify Monte Carlo uncertainty but do not alter those
decisions. mc_conf_level = 0.95 sets the confidence level
for these bounds. Small values are appropriate only for illustration;
operating characteristics must be calibrated with the Monte Carlo
settings prespecified for the design.
The thresholds \(Q_\ell\), \(S_\ell\), and \(F_\ell\) may be constant across looks or may vary by look. They interact with the final analysis threshold, number and timing of looks, endpoint delay, accrual rate, loss to follow-up, prior distribution, and maximum sample size.
If type I error is too high, possible remedies include increasing
prob_ha, increasing Qn or Sn,
reducing the number of looks, or altering follow-up requirements. If
power is too low, the maximum sample size, futility threshold, upper
thresholds, or final analysis threshold may need reconsideration. Each
change should be rechecked under null and alternative scenarios.
The quantity stop_and_fail is particularly useful when
tuning \(S_\ell\). It estimates how
often a trial stops accrual for expected success but does not meet the
final success criterion after follow-up is complete. If this is too
large, the expected-success threshold is usually too permissive for the
amount of uncertainty present at interim looks.
A group-sequential design usually indexes interim analyses by information, such as the number of observed events, and may stop immediately for efficacy when a boundary is crossed. A Goldilocks design indexes sample-size selection analyses by enrolled sample size and explicitly incorporates future follow-up of the currently enrolled cohort.
This distinction matters for delayed outcomes. A trial may enroll
many subjects before accumulating enough events for an event-driven
interim analysis. Goldilocks uses the partial information available
during accrual to decide whether additional subjects are needed. With
the default Qn = 1, success is determined at a single
preplanned final analysis after the enrolled subjects have completed
follow-up. A design with Qn < 1 can instead declare
terminal success at an interim look and therefore requires explicit
operating- characteristic calibration of that additional decision.
The time-to-event example in Broglio et al. (2014) uses a
Gamma-exponential prediction model. goldilocks extends this
to a piecewise-exponential model, so the hazard may change at
prespecified cut-points. This can be useful when there is a clinically
plausible early-risk period, but each additional interval adds
parameters and can make interim posteriors more diffuse.
The package also supports single-arm Bayesian Goldilocks designs by replacing the concurrent control with an external benchmark \(h_0\), often referred to as a performance goal (PG) or objective performance criterion (OPC). This is convenient for early-phase, rare-disease, or proof-of-concept settings, but validity then depends on the benchmark being transportable to the enrolled population.
For complete binary endpoints, method = "bayes-bin"
replaces the piecewise- exponential completed-data analysis with a
conjugate beta-binomial analysis. Pending endpoint statuses are still
imputed from the piecewise-exponential event-time model. These are
separate models rather than components of one joint Bayesian model: the
Gamma hazard prior used for imputation does not determine the Beta
event-probability prior used for completed-data analysis. Both priors
can affect predictive decisions when outcomes are pending. The analysis
output records prior_surv, prior_surv_final,
prior_bin, and the imputation horizon
end_of_study so that the complete statistical specification
can be reviewed.
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. doi:10.1080/10543406.2014.888569.
Farrington CP, Manning G. Test statistics and sample size formulae for comparative binomial trials with null hypothesis of non-zero risk difference or non-unity relative risk. Statistics in Medicine, 1990; 9: 1447-1454. doi:10.1002/sim.4780091208.
U.S. Food and Drug Administration. Adaptive Design Clinical Trials for Drugs and Biologics Guidance for Industry. December 2019. https://www.fda.gov/regulatory-information/search-fda-guidance-documents/adaptive-design-clinical-trials-drugs-and-biologics-guidance-industry.
U.S. Food and Drug Administration. Guidance for the Use of Bayesian Statistics in Medical Device Clinical Trials. February 5, 2010. https://www.fda.gov/media/71512/download.