Skip to contents

A DesignSeqOneByOne implementing classical stratified permuted-block randomization: subjects are assigned from a per-stratum queue of pre-shuffled treatment labels (a "block" of block_size labels, containing exactly round(block_size * prob_T) treated and the remainder control, in random order), refilled with a fresh randomly-ordered block of the same fixed size whenever a stratum's queue empties. This is the fixed-block-size, mandatory-stratification counterpart of DesignSeqOneByOneRandomBlockSize (which varies block size across draws and makes stratification optional): here, strata_cols is required, and a single fixed block_size is used for every stratum and every block, guaranteeing exact treatment/control balance within each stratum at every block boundary.

Block-size / prob_T compatibility. block_size must yield an integer number of treated subjects: the constructor errors unless abs(block_size * prob_T - round(block_size * prob_T)) <= 1e-10.

Per-stratum queues. As in DesignSeqOneByOneRandomBlockSize, private$strata_states is a hashed environment mapping each stratum key (concatenated strata_cols values, "NA" for missing) to the vector of not-yet-used assignments remaining in that stratum's current block; assign_wt() pops the next assignment, refilling with a fresh block when empty. draw_bootstrap_indices() resamples within strata by default (bootstrap_type = "within_blocks" or NULL) or resamples whole strata otherwise.

References

Zelen, M. (1974). "The randomization and stratification of patients to clinical trials." Journal of Chronic Diseases, 27(7-8), 365-375, doi:10.1016/0021-9681(74)90015-0 , for stratified permuted-block randomization. See also block randomisation for orientation, and DesignSeqOneByOneRandomBlockSize for the randomly-varying-block-size variant.

Super classes

Design -> DesignSeqOneByOne -> DesignSeqOneByOneSPBR

Methods

+ inherited public methods from DesignSeqOneByOne
+ inherited public methods from Design


DesignSeqOneByOneSPBR$new()

Initialize a stratified permuted-block sequential experimental design with fixed block size (see class documentation for the exact block-refill rule).

Usage

DesignSeqOneByOneSPBR$new(
  strata_cols,
  block_size = 4,
  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

strata_cols

A character vector of column names to use for stratification.

block_size

The size of the permuted blocks (fixed; see class documentation for its compatibility requirement with prob_T).

response_type

"continuous", "incidence", "proportion", "count", "survival", or "ordinal".

prob_T

Probability of treatment assignment.

include_is_missing_as_a_new_feature

Flag for missingness indicators.

n

The sample size.

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 `DesignSeqOneByOneSPBR` object


DesignSeqOneByOneSPBR$assign_wt()

Pop the next treatment assignment from the current subject's stratum block queue (see class documentation), refilling that queue with a freshly drawn fixed-size, randomly-ordered block first if it is empty.

Usage

DesignSeqOneByOneSPBR$assign_wt()

Returns

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


DesignSeqOneByOneSPBR$clone()

The objects of this class are cloneable with this method.

Usage

DesignSeqOneByOneSPBR$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.

Examples

seq_des = DesignSeqOneByOneSPBR$new(strata_cols = 'x1', n = 6, response_type = 'continuous')
seq_des$add_one_subject_to_experiment_and_assign(data.frame(x1 = factor(1, levels=1:2)))
#> [1] 1