StatsOtter Causal inference workflows
11
Workflow·2 steps

Design & analyze randomized experiments (experiment)

Summary by StatsOtter

Randomize treatment (complete, blocked, cluster) and estimate average effects with design-based variance — including cluster-randomized trials.

1

Input · what goes in

Experimental units with a treatment indicator and outcome (plus optional cluster/block IDs and covariates).

Show data format & exampleHide example
unit cluster Z Y
1 A 1 4.2
2 A 1 5.1
3 B 0 3.4
4 B 0 2.9
2

Pipeline · the recipe

↑ Click any step in the diagram to read its logic, code, assumptions & discussion.

1
Data prep

Randomize the treatment

Data preparation — shapes the raw inputs into what the estimator expects.

What happens here

Draw a complete randomization (here a 50/50 split over 100 units) with known assignment probabilities.

Reads from the input data Feeds into #2
Key code
# Install:  install.packages("experiment")
library(experiment)
set.seed(1)
z <- randomize(N = 100, ratio = c(0.5, 0.5))

Reference / docs ↗

Discussion on this step (0)
  • No comments on this step yet — be the first.
2
Estimation

Estimate the cluster-randomized ATE

The core estimate — where the causal quantity itself is computed.

What happens here

ATEcluster estimates the average effect under cluster randomization with the Imai–King–Nall design-based variance.

Formula
\hat\tau=\frac{1}{N}\sum_{j}\frac{n_j}{\bar n}\big(\bar Y_{j}^{T}-\bar Y_{j}^{C}\big)\quad(\text{cluster ATE})
Reads from #1 Feeds into the final output
Key code
out <- ATEcluster(Y = Y, Z = Z, grp = cluster, data = mydata)
summary(out)

Reference / docs ↗

Discussion on this step (0)
  • No comments on this step yet — be the first.
3

Output · what you get

Cluster-randomized ATE estimate with its design-based 95% confidence interval.
Fig 1Cluster-randomized ATE estimate with its design-based 95% confidence interval.

Result figure rendered by StatsOtter from the package's documented example — unofficial community showcase; all credit to the original authors.

Result · the numbers

\hat\tau=\frac{1}{N}\sum_{j}\frac{n_j}{\bar n}\big(\bar Y_{j}^{T}-\bar Y_{j}^{C}\big)\quad(\text{cluster ATE})

⚠️ Unofficial community showcase of experiment (docs). Not affiliated with the authors — all credit to Kosuke Imai & Zhichao Jiang; this summarizes public documentation.

What it does. experiment packages Imai's tools for the full life-cycle of a randomized study: drawing the randomization, and then estimating the average treatment effect with design-based standard errors that respect how units were assigned.

How it works. randomize() produces complete / blocked / cluster assignments with known probabilities. For analysis, ATEcluster() estimates the ATE under cluster randomization using the Imai–King–Nall design-based variance, and companion functions handle noncompliance. Inference comes from the assignment mechanism, not an outcome model.

Assumptions. Known randomization, SUTVA; the cluster estimator assumes clusters were the unit of assignment.

What you get — A randomized assignment vector and a design-based ATE estimate with a standard error and confidence interval.

Example output

Estimated Average Treatment Effect (ATE):
   est       se      ci.lower   ci.upper
  0.142    0.061     0.022      0.262

Number of clusters:        50
Number of observations:   500

Links: package · paper

Discussion (0)

  • No comments yet — start the conversation.