Skip to contents

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


DesignFixedCluster$is_a_cluster_capable()

Characterization: this design randomizes whole clusters (see class documentation), so it is cluster-structured by construction.

Usage

DesignFixedCluster$is_a_cluster_capable()

Returns

Always TRUE for this class.


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_col

The column name in the data that identifies the cluster for each subject.

response_type

The data type of response values.

prob_T

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

Flag for missingness indicators.

n

The sample size. If NULL (default), n is set to nrow(X_all) when the subjects are added with add_all_subjects_to_experiment(); a given n must equal nrow(X_all). Assigning before the subjects are added needs n (a covariate-free design such as iBCRD or Bernoulli can then assign without X).

verbose

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


DesignFixedCluster$clone()

The objects of this class are cloneable with this method.

Usage

DesignFixedCluster$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.

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()