
A Fixed, Blocked-and-Clustered Randomized Design
Source:R/design_fixed_blocked_cluster.R
DesignFixedBlockedCluster.RdA fixed-sample-size DesignFixed in which the unit of
randomization is the cluster, not the individual subject: within each block
(stratum, formed from strata_cols), whole clusters (identified by
cluster_col) are jointly randomized to treatment or control, so all subjects in
the same cluster always receive the same assignment. This is the design used when
individual-level randomization is infeasible or invalid (e.g. clusters are classrooms,
clinics, or households where within-cluster interference/spillover would violate
SUTVA under individual randomization), combined with blocking to improve precision by
comparing clusters only to other clusters in the same stratum.
Randomization mechanism. Blocking keys are computed per subject via
private$get_strata_keys() (shared with other
blocking-structure designs): categorical columns in
strata_cols are used as-is, continuous columns are discretized into
preferred_num_bins_for_continuous_covariate quantile-based bins, and multiple
strata_cols are combined into a single composite block key. Within each
resulting block, whole clusters (by cluster_col) are randomized to treatment
with probability prob_T via block_and_cluster_ra
(randomizr), which performs blocked-and-clustered complete random assignment:
within each block, clusters (not subjects) are permuted so that, subject to rounding,
the target proportion prob_T of clusters in that block is treated, and every
subject in a treated cluster receives \(w = 1\). r independent replicate
allocation columns are generated via replicate() (one randomizr call per
replicate; there is no batch/vectorized draw path for this design, unlike
DesignFixedBinaryMatch).
Cluster-aware bootstrap. draw_bootstrap_indices() overrides the default
subject-level bootstrap to resample at the cluster level via
resample_group_rows_cpp(): with bootstrap_type = "within_blocks"
(the default when bootstrap_type is NULL), clusters are resampled with
replacement within each block, preserving the block structure; otherwise, whole
blocks (strata) are themselves resampled with replacement. This mirrors the standard
cluster-robust bootstrap principle that resampling must occur at the level of the
randomization unit (clusters), not individual subjects, to yield a valid
variance/interval estimate under cluster-correlated outcomes.
References
Middleton, J. A., and Aronow, P. M. (2015). "Unbiased estimation of the average treatment effect in cluster-randomized experiments." Statistics, Politics and Policy, 6(1-2), 39-75, doi:10.1515/spp-2013-0002 , for blocked/clustered randomized-assignment inference; see also the randomizr package vignette for the assignment-generation conventions this design relies on, and cluster randomized controlled trial for orientation.
Super classes
Design -> DesignFixed -> DesignFixedBlockedCluster
Methods
+ inherited public methods from DesignFixed
+ inherited public methods from Design
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$draw_ws_according_to_design()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_kk_matching_capable()Design$is_blocking_design()Design$is_fixed_sample_size()Design$is_matching_design()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()
DesignFixedBlockedCluster$is_a_cluster_capable()
Characterization: this design randomizes whole clusters (see class documentation), so it is cluster-structured by construction.
DesignFixedBlockedCluster$new()
Initialize a blocked and cluster randomized fixed experimental design.
Usage
DesignFixedBlockedCluster$new(
strata_cols,
cluster_col,
response_type,
prob_T = 0.5,
include_is_missing_as_a_new_feature = TRUE,
n = NULL,
preferred_num_bins_for_continuous_covariate = 2,
num_bins_for_continuous_covariate = NULL,
verbose = FALSE,
missingness_method = "impute",
design_formula = ~.,
seed = NULL
)Arguments
strata_colsA character vector of column names to use for stratification (blocks).
cluster_colThe column name in the data that identifies the cluster for each subject.
response_typeThe data type of response values.
prob_TThe target probability that a given cluster within a block is assigned to treatment (subjects inherit their cluster's assignment).
include_is_missing_as_a_new_featureFlag for missingness indicators.
nThe sample size.
preferred_num_bins_for_continuous_covariateThe number of quantile bins to use for continuous strata. Default is 2.
num_bins_for_continuous_covariateDeprecated alias for `preferred_num_bins_for_continuous_covariate`.
verboseFlag for verbosity.
missingness_methodHow to handle missing values in covariates.
design_formulaA formula object.
seedInteger seed for reproducibility.