
A Sequential Design Guaranteeing Exact Terminal Balance (Random Allocation Rule)
Source:R/design_seq_one_by_one_ibcrd.R
DesignSeqOneByOneiBCRD.RdA DesignSeqOneByOne implementing the "random
allocation rule" (a sequential realization of complete randomization): treatment is
assigned to each arriving subject with probability equal to the fraction of
remaining treatment slots among all remaining slots,
\(\Pr(w_t = 1) = n_{T,\mathrm{rem}} / (n_{T,\mathrm{rem}} + n_{C,\mathrm{rem}})\),
where \(n_{T,\mathrm{rem}} = \mathrm{round}(n \cdot prob\_T) - n_T\) and
\(n_{C,\mathrm{rem}} = (n - \mathrm{round}(n \cdot prob\_T)) - n_C\) are the
treatment/control slots not yet used, given the running counts \(n_T\), \(n_C\).
This guarantees the realized sequence, once all \(n\) subjects have arrived, has
exactly \(\mathrm{round}(n \cdot prob\_T)\) treated subjects — the same
terminal allocation-count guarantee as
DesignFixediBCRD's complete randomization, but
realized online as subjects arrive one at a time rather than all at once, and with
every prefix of the sequence itself drawn from the correct conditional (hypergeometric)
distribution given the slots used so far. If a slot type is exhausted
(\(n_{T,\mathrm{rem}} \le 0\) or \(n_{C,\mathrm{rem}} \le 0\)), the remaining
subjects are deterministically assigned to whichever type still has open slots.
n is required. The rule balances toward the planned sample size, so
n must be supplied at construction; n = NULL is an error. When the
sample size is not known in advance, use
DesignSeqOneByOneBernoulli (or another
sequential design that does not need n). Before v1.0.6, n = NULL was
accepted and fell back to Bernoulli assignment, but the randomization draws still
forced exact balance, so its randomization distribution was wrong.
Rounding of the treated count. \(\mathrm{round}\) is R's round(),
which rounds a .5 tie to the even integer (n = 21, prob_T = 0.5 gives 10
treated). The randomization redraws (draw_ws_according_to_design()) use the
same count, so every redraw has exactly as many treated subjects as the trial. (Before
v1.0.6 the redraws rounded ties away from zero, giving one more treated subject than
the trial when \(n \cdot prob\_T\) ended in .5.) DesignFixediBCRD rounds such
ties up instead, so at a tie the two designs differ by one treated subject.
Single implicit block. add_one_subject_to_experiment_and_assign()
overrides the inherited method only to additionally set private$m to a
constant vector of 1s (a single block containing every subject enrolled so far)
after each assignment, mirroring the fixed-sample
DesignFixediBCRD's single-block convention for
shared blocking/matching machinery.
References
Rosenberger, W. F., and Lachin, J. M. (2016). Randomization in
Clinical Trials: Theory and Practice (2nd ed.), Wiley, for the random allocation
rule as a sequential implementation of complete randomization. See also
DesignFixediBCRD for the fixed-sample (all-at-once)
version of the same terminal randomization law.
Super classes
Design -> DesignSeqOneByOne -> DesignSeqOneByOneiBCRD
Methods
+ inherited public methods from DesignSeqOneByOne
+ inherited public methods from Design
Design$add_all_subject_responses()Design$add_one_subject_response()Design$any_censoring()Design$applicable_inference_class_names()Design$assert_all_responses_recorded()Design$assert_all_subjects_arrived()Design$assert_even_allocation()Design$assert_fixed_sample()Design$capabilities()Design$check_experiment_completed()Design$duplicate()Design$get_X()Design$get_X_imp()Design$get_X_raw()Design$get_design_formula()Design$get_edi_version_created()Design$get_effective_dead()Design$get_effective_time()Design$get_missingness_method()Design$get_n()Design$get_ordinal_levels()Design$get_original_ordinal_levels()Design$get_prob_T()Design$get_response_type()Design$get_response_type_original()Design$get_t()Design$get_w()Design$get_y()Design$get_y_L()Design$get_y_R()Design$get_y_original()Design$has_general_censoring()Design$incompatible_inference_classes_due_to_design_structure()Design$is_a_bernoulli_capable()Design$is_a_cluster_capable()Design$is_a_kk_matching_capable()Design$is_blocking_design()Design$is_fixed_sample_size()Design$is_matching_design()Design$overwrite_all_subject_assignments()Design$prepare_for_resampling_replay()Design$randomization_family()Design$supports()Design$supports_randomization_draw()Design$supports_resampling()Design$supports_resampling_replay()Design$transform_y()Design$unavailable_inference_classes_due_to_missing_packages()Design$warm_all_subject_data_cache()
DesignSeqOneByOneiBCRD$new()
Initialize a sequential design targeting exact terminal treatment/control balance (see class documentation for the assignment rule).
Usage
DesignSeqOneByOneiBCRD$new(
response_type,
prob_T = 0.5,
include_is_missing_as_a_new_feature = TRUE,
n = NULL,
verbose = FALSE,
missingness_method = "impute",
design_formula = ~.,
seed = NULL
)Arguments
response_type"continuous", "incidence", "proportion", "count", "survival", or "ordinal".
prob_TTarget probability of treatment assignment; the terminal number of treated subjects is fixed at
round(n * prob_T)(see class documentation).include_is_missing_as_a_new_featureFlag for missingness indicators.
nThe planned (target) sample size, required (a positive integer): the rule balances toward it.
NULLis an error; useDesignSeqOneByOneBernoulliwhen the sample size is not known in advance.verboseA flag for verbosity.
missingness_methodHow to handle missing values in covariates.
design_formulaA formula object.
seedInteger seed for reproducibility.
DesignSeqOneByOneiBCRD$add_one_subject_to_experiment_and_assign()
Add one subject to the experiment and assign treatment via
assign_wt() (delegating to the inherited
DesignSeqOneByOne$add_one_subject_to_experiment_and_assign()),
then set private$m to a single-block vector of 1s covering every
subject enrolled so far (see class documentation), overwritten on every
call rather than only once all subjects have arrived.
DesignSeqOneByOneiBCRD$assign_wt()
Draw the next subject's treatment assignment via the random allocation rule (see class documentation): with probability equal to the fraction of remaining treatment slots among all remaining slots, or a deterministic assignment if one slot type is exhausted.
Examples
seq_des = DesignSeqOneByOneiBCRD$new(n = 6, response_type = 'continuous')
seq_des$add_one_subject_to_experiment_and_assign(data.frame(x1 = rnorm(1)))
#> [1] 0