A fixed-sample-size DesignFixed in which whole clusters
of subjects (identified by cluster_col), rather than individual subjects, are
the unit of randomization: every subject in a given cluster always receives the same
treatment assignment. This is the unblocked analog of
DesignFixedBlockedCluster — there is no
stratification step here, so clusters are randomized to treatment as a single pool
rather than within strata. Cluster-level randomization is required whenever
individual-level randomization would create within-cluster interference/spillover
that violates SUTVA (e.g. clusters are classrooms, clinics, villages, or households),
at the cost of an effective sample size driven by the number of clusters, not
subjects, and a corresponding need for cluster-aware inference.
Randomization mechanism. draw_ws_raw(r) extracts each subject's
cluster ID from cluster_col (erroring if any are missing) and calls
block_ra_batch() once for all replicates (same law as randomizr's cluster_ra), which
performs complete random assignment at the cluster level: subject to rounding,
prob_T of clusters are assigned to treatment, and all subjects sharing a
cluster inherit that cluster's assignment. r independent replicate columns are
generated in one vectorized block_ra_batch() pass (no per-replicate loop).
Cluster-aware bootstrap. draw_bootstrap_indices() overrides the
default subject-level bootstrap to resample whole clusters with replacement (via
resample_group_rows_cpp()) rather than individual rows, since outcomes are
correlated within a cluster (shared assignment plus, typically, shared context) and
the exchangeable resampling unit for a valid bootstrap variance/interval estimate is
therefore the cluster, not the subject.
Cluster-aware asymptotic inference. cluster_col is an
assignment-unit label and is excluded from the default ~ . covariate
formula. InferenceContinOLS and
InferenceContinLin use a CR2
(Bell-McCaffrey) cluster-robust standard error with Bell-McCaffrey (Satterthwaite) degrees of
freedom (G - 1 if that cannot be computed) on this design. A user
model_formula that uses the cluster column warns
(edi_cluster_col_in_model_formula_warning), because treatment is
collinear with the cluster indicators. Other regression-based inference classes still treat subjects as
independent in their Wald/score/LR standard errors; for those use randomization
(compute_rand_*), the cluster-resampling bootstrap
(compute_bootstrap_*), or the cluster jackknife
(compute_jackknife_wald_*(unit = "cluster")).
Interim warning. Until per-class cluster-robust variances exist, such a
class emits one warning per inference object and procedure family (Wald; or
likelihood-based: score, gradient, likelihood-ratio, Bartlett and the parametric
bootstrap) saying subjects are treated as independent, so SEs, p-values and CIs
may be too narrow. OLS and Lin are silent for Wald inference (CR2), but their
likelihood-based and parametric-bootstrap procedures still warn. Randomization,
bootstrap and jackknife routes do not warn. The condition has class
edi_cluster_independence_warning; silence it with
suppressWarnings(expr, classes = "edi_cluster_independence_warning").
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
. See also
cluster
randomized controlled trial for orientation, and
DesignFixedBlockedCluster for the
blocked variant of this design.
Super classes
Design -> DesignFixed -> DesignFixedCluster
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$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()
DesignFixedCluster$is_a_cluster_capable()
Characterization: this design randomizes whole clusters (see class documentation), so it is cluster-structured by construction.
DesignFixedCluster$new()
Initialize a cluster randomized fixed experimental design (no
blocking/stratification; see
DesignFixedBlockedCluster if
stratification is also needed).
Usage
DesignFixedCluster$new(
cluster_col,
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
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 is assigned to treatment (subjects inherit their cluster's assignment). It is the share of clusters treated, not of subjects: with unequal cluster sizes the share of subjects treated varies from draw to draw around it.
include_is_missing_as_a_new_featureFlag for missingness indicators.
nThe sample size. If
NULL(default),nis set tonrow(X_all)when the subjects are added withadd_all_subjects_to_experiment(); a givennmust equalnrow(X_all). Assigning before the subjects are added needsn(a covariate-free design such as iBCRD or Bernoulli can then assign withoutX).verboseFlag for verbosity.
missingness_methodHow to handle missing values in covariates.
design_formulaA formula object.
seedInteger seed for reproducibility.
Examples
des = DesignFixedCluster$new(n = 20, response_type = 'continuous', cluster_col = 'cl')
X = data.frame(x = rnorm(20), cl = factor(rep(1:5, each = 4)))
des$add_all_subjects_to_experiment(X)
des$assign_w_to_all_subjects()
