Skip to contents

A 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


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_T

Target 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_feature

Flag for missingness indicators.

n

The planned (target) sample size, required (a positive integer): the rule balances toward it. NULL is an error; use DesignSeqOneByOneBernoulli when the sample size is not known in advance.

verbose

A flag for verbosity.

missingness_method

How to handle missing values in covariates.

design_formula

A formula object.

seed

Integer seed for reproducibility.

Returns

A new `DesignSeqOneByOneiBCRD` object


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.

Usage

DesignSeqOneByOneiBCRD$add_one_subject_to_experiment_and_assign(x_new)

Arguments

x_new

A data frame with one row representing the new subject's covariates.

Returns

The treatment assignment (0 or 1) for the newly added subject.


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.

Usage

DesignSeqOneByOneiBCRD$assign_wt()

Returns

The treatment assignment (0 or 1) for the next subject.


DesignSeqOneByOneiBCRD$clone()

The objects of this class are cloneable with this method.

Usage

DesignSeqOneByOneiBCRD$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.

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