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 named list 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.

Jackknife. The jackknife's automatic deletion unit is the permuted block (unit = "permuted_block"), the randomization unit of this design: within each stratum, the enrollees in order fill blocks of block_size, and a trailing partial block (a stratum's last, incomplete block) is merged into that stratum's previous block; a stratum with only a partial block is one unit. The variance pools the replicates' spread within strata (the stratified jackknife of Wolter 2007, Introduction to Variance Estimation, 2nd ed., Sec. 4.5; formulas in InferenceJackknife). A stratum with one block contributes nothing. The jackknife-Wald test and interval use the t distribution with \(\sum_h (n_h - 1)\) degrees of freedom, \(n_h\) the number of blocks in stratum \(h\) (v1.0.6-TODO-231). Before EDI 1.0.6 a replicate deleted a whole stratum, which left only 2-4 replicates on typical data (v1.0.6-TODO-4). When any stratum holds fewer than 10 permuted-block units, the automatic unit is one subject within its stratum instead (unit = "observation_within_block", the same stratified jackknife with subjects as units): with few blocks in a stratum the permuted-block jackknife-Wald test was too liberal (v1.0.6-TODO-270). An explicit unit = "permuted_block" still deletes permuted blocks.

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] 0