Simulate one paired replicate for post hoc design evaluation
single_paired_rep.RdSimulates a single trial and records everything needed to evaluate a family of designs afterwards, without baking any design into the run: interim statistics and the predictive probability (PP) at the futility look, and the test statistics at the efficacy look and the final analysis of the real trial (which is never stopped here).
Usage
single_paired_rep(
i,
seed,
n_c,
n_t,
total_events,
futility_IF,
efficacy_IF = 0.75,
design,
control_model,
effect_model,
recruitment_model,
truth = NULL,
force_state = NULL,
analysis_model_LRT,
mw_t_stars = c(2, 6),
update_priors_sims,
PP_sims,
compute_PP = TRUE
)Arguments
- i
Replicate index.
- seed
Base seed. Replicate
iusesset.seed(seed * 1e5 + i), which must be below.Machine$integer.max; the JAGS seed is drawn from that stream, so the replicate is fully reproducible.- n_c, n_t
Planned number of patients in the control / treatment arm.
- total_events
Maximum planned number of events.
- futility_IF
Information fraction of the futility (PP) look.
- efficacy_IF
Information fraction of the interim efficacy look (default 0.75).
- design
An
rpactgroup-sequential design containing the efficacy look atefficacy_IFand the final analysis (and optionally the futility look, with zero alpha spent).- control_model, effect_model
The analysis prior, used for the interim posterior update (see
update_priors).control_model$parameter_modemust be"Distribution".- recruitment_model
Recruitment specification. Must be
method = "power"withpower = 1(seePP_func).- truth
Either a list with the true
lambda_c,delay_time,post_delay_HRand optionallygamma_c(exponential control arm ifNULL) andstate, orNULL, in which case the truth is drawn fromcontrol_modelandeffect_modelviasimulate_trial_with_recruitment(), optionally with the latent state fixed byforce_state.- force_state
NULL, or 1 (no separation), 2 (immediate separation) or 3 (delayed separation). Only used whentruth = NULL.- analysis_model_LRT
Analysis specification for the log-rank test (
method = "LRT",alpha,alternative_hypothesis), used for the PP calculation and the*_LRTstatistics.- mw_t_stars
Values of \(t^*\) for the modestly weighted log-rank statistics (default
c(2, 6)).- update_priors_sims
Number of posterior samples per chain (required when
compute_PP = TRUE).- PP_sims
Number of posterior-predictive draws (required when
compute_PP = TRUE).- compute_PP
If
FALSE, skip the interim posterior update and the PP calculation:PP_val,converged,rhat_max,n_nonfinite_rhat,P_Z1,P_Z2andP_Z3areNA, and all other columns are identical to those fromcompute_PP = TRUEwith the same seed. Such output supports rules D1, D2, D4 and D5 but not D3. DefaultTRUE.
Value
A one-row data frame with columns: rep_id,
seed_used, state, true_lambda_c, true_gamma_c
(1 for an exponential control arm), true_delay, true_HR;
interim t_int, n_int, frac_recruited_int (enrolled
/ planned), fu_gt3_int, fu_gt6_int (fraction of enrolled
treated patients with follow-up t_int - rec_time above 3 and 6),
Z_int_LRT, Z_int_MW_t<t>; PP_val, converged,
rhat_max, n_nonfinite_rhat, P_Z1, P_Z2,
P_Z3; t_eff, n_eff, Z_eff_LRT,
Z_eff_MW_t<t>, t_fin, n_fin, Z_fin_LRT,
Z_fin_MW_t<t>; the D2 outcome continuation_success,
continuation_stop_time, continuation_sample_size; aliases
t_interim and sample_size_interim (for
summarize_grid_by_kappa); and error (NA, or
the error message if the replicate failed, in which case all other
outcome columns are NA).
Details
All designs are then summaries of the returned columns. With critical
values \(c_{eff}\), \(c_{fin}\) from design and a final-only
critical value \(c_1\):
D1 (fixed design): success if
Z_fin_LRT > c_1.D2 (efficacy look only): success if
Z_eff_LRT > c_eff, otherwiseZ_fin_LRT > c_fin. This iscontinuation_success.D3 (D2 plus PP futility): stop for futility if
PP_val < kappa; seesummarize_grid_by_kappa.D4, D5 (D2 plus Z futility): stop for futility if
Z_int_LRT(orZ_int_MW_t*) is below a cutoff.