Randomization & Blocking Experimental Design Lens
Philosophical Mode: Design-Structural
Primary Question: "Where does comparability come from?"
Focus: Assignment Mechanisms, Blocking Factors, Stratification, Balanced Designs, Replication
When to Use
- Experiment uses randomization or structured assignment
- Need to verify blocking and stratification
- Checking for pseudoreplication
- User invokes
/exp-lens-randomization-blocking or /make-experiment-diag randomization
Critical Constraints
NEVER:
- Modify any source code files
- Do not litter the codebase with useless comments, TODO markers, or explanatory annotations — the skill output and diagram speak for themselves
- Assume comparability without tracing its source
ALWAYS:
- Trace the exact mechanism that creates comparability between treatment groups
- Identify every nuisance factor and how it is controlled
- Flag pseudoreplication risks (replicating at the wrong unit)
- Verify that replication is adequate for the claimed inferential precision
- BEFORE creating any diagram, LOAD the
/mermaid skill using the Skill tool - this is MANDATORY
Analysis Workflow
Step 1: Launch Parallel Exploration Subagents
Spawn Explore subagents to investigate:
Assignment Mechanism
- Find how units are assigned to conditions
- Look for:
random, assign, shuffle, permute, allocate, condition, arm, group
Blocking & Stratification
- Find blocking variables and stratification logic
- Look for:
block, stratify, batch, fold, group_by, cluster, site
Replication Structure
- Find how many runs/replicates per condition
- Look for:
replicate, repeat, n_runs, n_trials, seed_list, iteration
Order & Timing Effects
- Find whether order of execution matters
- Look for:
order, sequence, schedule, first, last, warm_up, cold_start
Exclusion & Attrition
- Find unit exclusion or retry logic
- Look for:
exclude, drop, filter, retry, timeout, fail, skip
Step 2: Map the Allocation Flow
Map the complete allocation flow from population of units through assignment to analysis. Identify:
- What is the randomization unit?
- What blocking factors are used?
- Is replication adequate?
- Are there confounds between treatment and nuisance factors (time, hardware, order)?
Step 3: CRITICAL — Analyze Comparability Source
For every treatment contrast:
- Comparability mechanism: What makes the groups comparable — randomization, matching, blocking, or assumption?
- Randomization quality: If randomization — is it truly random or deterministic-with-seed? Could seed choice affect results?
- Block crossing: If blocked — do blocks fully cross with treatments, or are some treatments confounded with blocks?
- Replication level: Is the replication unit the same as the randomization unit? If not, pseudoreplication risk exists.
- Temporal confounds: Could time-of-execution differences (cache state, load, ordering) introduce systematic bias?
Distinguish clearly:
- True randomization: Independent draws, unconfounded with nuisance
- Blocked randomization: Randomization within homogeneous blocks
- Matched pairs: Units matched on confounders before assignment
- Deterministic assignment: Fixed seed or rotation — not truly random
Step 4: Create the Diagram
Use flowchart with:
Direction: TB (population flows down through allocation to analysis)
Subgraphs:
POPULATION/POOL
BLOCKING
RANDOMIZATION
TREATMENT ARMS
ANALYSIS
Node Styling:
cli class: population/pool entry
phase class: blocking/stratification nodes
handler class: randomization mechanism
stateNode class: treatment arm conditions
output class: analysis endpoints
gap class: pseudoreplication or confound risks
detector class: balance checks
Step 5: Write Output
Write the diagram to: temp/exp-lens-randomization-blocking/exp_diag_randomization_blocking_{YYYY-MM-DD_HHMMSS}.md
Output Template
# Randomization & Blocking Diagram: {System Name}
**Lens:** Randomization & Blocking (Design-Structural)
**Question:** Where does comparability come from?
**Date:** {YYYY-MM-DD}
**Scope:** {What was analyzed}
## Design Structure
| Factor | Levels | Type | Crossed/Nested | Notes |
|--------|--------|------|----------------|-------|
| {Factor 1} | {levels} | Treatment | Crossed | {notes} |
| {Factor 2} | {levels} | Block | Nested | {notes} |
| {Factor 3} | {levels} | Nuisance | Controlled | {notes} |
## Randomization & Blocking Diagram
```mermaid
%%{init: {'flowchart': {'nodeSpacing': 50, 'rankSpacing': 60, 'curve': 'basis'}}}%%
flowchart TB
%% CLASS DEFINITIONS %%
classDef cli fill:#1a237e,stroke:#7986cb,stroke-width:2px,color:#fff;
classDef stateNode fill:#004d40,stroke:#4db6ac,stroke-width:2px,color:#fff;
classDef handler fill:#e65100,stroke:#ffb74d,stroke-width:2px,color:#fff;
classDef phase fill:#6a1b9a,stroke:#ba68c8,stroke-width:2px,color:#fff;
classDef newComponent fill:#2e7d32,stroke:#81c784,stroke-width:2px,color:#fff;
classDef output fill:#00695c,stroke:#4db6ac,stroke-width:2px,color:#fff;
classDef detector fill:#b71c1c,stroke:#ef5350,stroke-width:2px,color:#fff;
classDef gap fill:#ff6f00,stroke:#ffa726,stroke-width:2px,color:#000;
classDef integration fill:#c62828,stroke:#ef9a9a,stroke-width:2px,color:#fff;
subgraph Pool ["POPULATION/POOL"]
direction TB
UNITS["{Unit Type}<br/>━━━━━━━━━━<br/>N={total units}"]
end
subgraph Blocking ["BLOCKING"]
direction TB
BLK1["{Block Factor 1}<br/>━━━━━━━━━━<br/>{levels}"]
BLK2["{Block Factor 2}<br/>━━━━━━━━━━<br/>{levels}"]
end
subgraph Randomization ["RANDOMIZATION"]
direction TB
RAND["{Assignment Mechanism}<br/>━━━━━━━━━━<br/>{random/deterministic/matched}"]
end
subgraph Arms ["TREATMENT ARMS"]
direction TB
ARM1["{Treatment A}<br/>━━━━━━━━━━<br/>n={replicates}"]
ARM2["{Treatment B}<br/>━━━━━━━━━━<br/>n={replicates}"]
CTRL["{Control}<br/>━━━━━━━━━━<br/>n={replicates}"]
end
subgraph Analysis ["ANALYSIS"]
direction TB
ENDPOINT["{Primary Endpoint}<br/>━━━━━━━━━━<br/>{estimand}"]
BALANCE["{Balance Check}<br/>━━━━━━━━━━<br/>Verify comparability"]
end
PSEUDO["{Pseudoreplication Risk}<br/>━━━━━━━━━━<br/>{unit mismatch description}"]
CONFOUND["{Confound Risk}<br/>━━━━━━━━━━<br/>{nuisance factor description}"]
UNITS --> BLK1
UNITS --> BLK2
BLK1 --> RAND
BLK2 --> RAND
RAND --> ARM1
RAND --> ARM2
RAND --> CTRL
ARM1 --> ENDPOINT
ARM2 --> ENDPOINT
CTRL --> ENDPOINT
ENDPOINT --> BALANCE
PSEUDO -.->|risk| RAND
CONFOUND -.->|risk| ARM1
%% CLASS ASSIGNMENTS %%
class UNITS cli;
class BLK1,BLK2 phase;
class RAND handler;
class ARM1,ARM2,CTRL stateNode;
class ENDPOINT,BALANCE output;
class PSEUDO,CONFOUND gap;
class BALANCE detector;
Color Legend:
| Color |
Category |
Description |
| Dark Blue |
Population |
Units entering the experiment |
| Purple |
Blocking |
Blocking and stratification factors |
| Orange |
Randomization |
Assignment mechanism |
| Dark Teal |
Treatment Arms |
Conditions and replicates |
| Teal |
Analysis |
Endpoints and balance checks |
| Yellow/Amber |
Risks |
Pseudoreplication and confound risks |
Comparability Assessment
| Contrast |
Comparability Source |
Quality |
Risk |
| {A vs B} |
{mechanism} |
Strong/Weak |
{risk description} |
| {A vs Control} |
{mechanism} |
Strong/Weak |
{risk description} |
Replication Summary
| Condition |
N (units) |
N (replicates) |
Randomization Unit |
Analysis Unit |
Pseudoreplication? |
| {Arm 1} |
{n} |
{r} |
{unit} |
{unit} |
Yes/No |
| {Arm 2} |
{n} |
{r} |
{unit} |
{unit} |
Yes/No |
---
## Pre-Diagram Checklist
Before creating the diagram, verify:
- [ ] LOADED `/mermaid` skill using the Skill tool
- [ ] Using ONLY classDef styles from the mermaid skill (no invented colors)
- [ ] Diagram will include a color legend table
---
## Related Skills
- `/make-experiment-diag` - Parent skill for lens selection
- `/mermaid` - MUST BE LOADED before creating diagram
- `/exp-lens-causal-assumptions` - For causal structure analysis
- `/exp-lens-unit-interference` - For interference and spillover risks
1---2name: exp-lens-randomization-blocking3description: Create Randomization & Blocking experimental design diagram showing assignment mechanisms, blocking factors, and comparability sources. Design-Structural lens answering "Where does comparability come from?"4---56# Randomization & Blocking Experimental Design Lens78**Philosophical Mode:** Design-Structural9**Primary Question:** "Where does comparability come from?"10**Focus:** Assignment Mechanisms, Blocking Factors, Stratification, Balanced Designs, Replication1112## When to Use1314- Experiment uses randomization or structured assignment15- Need to verify blocking and stratification16- Checking for pseudoreplication17- User invokes `/exp-lens-randomization-blocking` or `/make-experiment-diag randomization`1819## Critical Constraints2021**NEVER:**22- Modify any source code files23- Do not litter the codebase with useless comments, TODO markers, or explanatory annotations — the skill output and diagram speak for themselves24- Assume comparability without tracing its source2526**ALWAYS:**27- Trace the exact mechanism that creates comparability between treatment groups28- Identify every nuisance factor and how it is controlled29- Flag pseudoreplication risks (replicating at the wrong unit)30- Verify that replication is adequate for the claimed inferential precision31- BEFORE creating any diagram, LOAD the `/mermaid` skill using the Skill tool - this is MANDATORY3233---3435## Analysis Workflow3637### Step 1: Launch Parallel Exploration Subagents3839Spawn Explore subagents to investigate:4041**Assignment Mechanism**42- Find how units are assigned to conditions43- Look for: `random`, `assign`, `shuffle`, `permute`, `allocate`, `condition`, `arm`, `group`4445**Blocking & Stratification**46- Find blocking variables and stratification logic47- Look for: `block`, `stratify`, `batch`, `fold`, `group_by`, `cluster`, `site`4849**Replication Structure**50- Find how many runs/replicates per condition51- Look for: `replicate`, `repeat`, `n_runs`, `n_trials`, `seed_list`, `iteration`5253**Order & Timing Effects**54- Find whether order of execution matters55- Look for: `order`, `sequence`, `schedule`, `first`, `last`, `warm_up`, `cold_start`5657**Exclusion & Attrition**58- Find unit exclusion or retry logic59- Look for: `exclude`, `drop`, `filter`, `retry`, `timeout`, `fail`, `skip`6061### Step 2: Map the Allocation Flow6263Map the complete allocation flow from population of units through assignment to analysis. Identify:64- What is the randomization unit?65- What blocking factors are used?66- Is replication adequate?67- Are there confounds between treatment and nuisance factors (time, hardware, order)?6869### Step 3: CRITICAL — Analyze Comparability Source7071For every treatment contrast:72- **Comparability mechanism**: What makes the groups comparable — randomization, matching, blocking, or assumption?73- **Randomization quality**: If randomization — is it truly random or deterministic-with-seed? Could seed choice affect results?74- **Block crossing**: If blocked — do blocks fully cross with treatments, or are some treatments confounded with blocks?75- **Replication level**: Is the replication unit the same as the randomization unit? If not, pseudoreplication risk exists.76- **Temporal confounds**: Could time-of-execution differences (cache state, load, ordering) introduce systematic bias?7778Distinguish clearly:79- **True randomization**: Independent draws, unconfounded with nuisance80- **Blocked randomization**: Randomization within homogeneous blocks81- **Matched pairs**: Units matched on confounders before assignment82- **Deterministic assignment**: Fixed seed or rotation — not truly random8384### Step 4: Create the Diagram8586Use flowchart with:8788**Direction:** `TB` (population flows down through allocation to analysis)8990**Subgraphs:**91- `POPULATION/POOL`92- `BLOCKING`93- `RANDOMIZATION`94- `TREATMENT ARMS`95- `ANALYSIS`9697**Node Styling:**98- `cli` class: population/pool entry99- `phase` class: blocking/stratification nodes100- `handler` class: randomization mechanism101- `stateNode` class: treatment arm conditions102- `output` class: analysis endpoints103- `gap` class: pseudoreplication or confound risks104- `detector` class: balance checks105106### Step 5: Write Output107108Write the diagram to: `temp/exp-lens-randomization-blocking/exp_diag_randomization_blocking_{YYYY-MM-DD_HHMMSS}.md`109110---111112## Output Template113114```markdown115# Randomization & Blocking Diagram: {System Name}116117**Lens:** Randomization & Blocking (Design-Structural)118**Question:** Where does comparability come from?119**Date:** {YYYY-MM-DD}120**Scope:** {What was analyzed}121122## Design Structure123124| Factor | Levels | Type | Crossed/Nested | Notes |125|--------|--------|------|----------------|-------|126| {Factor 1} | {levels} | Treatment | Crossed | {notes} |127| {Factor 2} | {levels} | Block | Nested | {notes} |128| {Factor 3} | {levels} | Nuisance | Controlled | {notes} |129130## Randomization & Blocking Diagram131132```mermaid133%%{init: {'flowchart': {'nodeSpacing': 50, 'rankSpacing': 60, 'curve': 'basis'}}}%%134flowchart TB135 %% CLASS DEFINITIONS %%136 classDef cli fill:#1a237e,stroke:#7986cb,stroke-width:2px,color:#fff;137 classDef stateNode fill:#004d40,stroke:#4db6ac,stroke-width:2px,color:#fff;138 classDef handler fill:#e65100,stroke:#ffb74d,stroke-width:2px,color:#fff;139 classDef phase fill:#6a1b9a,stroke:#ba68c8,stroke-width:2px,color:#fff;140 classDef newComponent fill:#2e7d32,stroke:#81c784,stroke-width:2px,color:#fff;141 classDef output fill:#00695c,stroke:#4db6ac,stroke-width:2px,color:#fff;142 classDef detector fill:#b71c1c,stroke:#ef5350,stroke-width:2px,color:#fff;143 classDef gap fill:#ff6f00,stroke:#ffa726,stroke-width:2px,color:#000;144 classDef integration fill:#c62828,stroke:#ef9a9a,stroke-width:2px,color:#fff;145146 subgraph Pool ["POPULATION/POOL"]147 direction TB148 UNITS["{Unit Type}<br/>━━━━━━━━━━<br/>N={total units}"]149 end150151 subgraph Blocking ["BLOCKING"]152 direction TB153 BLK1["{Block Factor 1}<br/>━━━━━━━━━━<br/>{levels}"]154 BLK2["{Block Factor 2}<br/>━━━━━━━━━━<br/>{levels}"]155 end156157 subgraph Randomization ["RANDOMIZATION"]158 direction TB159 RAND["{Assignment Mechanism}<br/>━━━━━━━━━━<br/>{random/deterministic/matched}"]160 end161162 subgraph Arms ["TREATMENT ARMS"]163 direction TB164 ARM1["{Treatment A}<br/>━━━━━━━━━━<br/>n={replicates}"]165 ARM2["{Treatment B}<br/>━━━━━━━━━━<br/>n={replicates}"]166 CTRL["{Control}<br/>━━━━━━━━━━<br/>n={replicates}"]167 end168169 subgraph Analysis ["ANALYSIS"]170 direction TB171 ENDPOINT["{Primary Endpoint}<br/>━━━━━━━━━━<br/>{estimand}"]172 BALANCE["{Balance Check}<br/>━━━━━━━━━━<br/>Verify comparability"]173 end174175 PSEUDO["{Pseudoreplication Risk}<br/>━━━━━━━━━━<br/>{unit mismatch description}"]176 CONFOUND["{Confound Risk}<br/>━━━━━━━━━━<br/>{nuisance factor description}"]177178 UNITS --> BLK1179 UNITS --> BLK2180 BLK1 --> RAND181 BLK2 --> RAND182 RAND --> ARM1183 RAND --> ARM2184 RAND --> CTRL185 ARM1 --> ENDPOINT186 ARM2 --> ENDPOINT187 CTRL --> ENDPOINT188 ENDPOINT --> BALANCE189 PSEUDO -.->|risk| RAND190 CONFOUND -.->|risk| ARM1191192 %% CLASS ASSIGNMENTS %%193 class UNITS cli;194 class BLK1,BLK2 phase;195 class RAND handler;196 class ARM1,ARM2,CTRL stateNode;197 class ENDPOINT,BALANCE output;198 class PSEUDO,CONFOUND gap;199 class BALANCE detector;200```201202**Color Legend:**203| Color | Category | Description |204|-------|----------|-------------|205| Dark Blue | Population | Units entering the experiment |206| Purple | Blocking | Blocking and stratification factors |207| Orange | Randomization | Assignment mechanism |208| Dark Teal | Treatment Arms | Conditions and replicates |209| Teal | Analysis | Endpoints and balance checks |210| Yellow/Amber | Risks | Pseudoreplication and confound risks |211212## Comparability Assessment213214| Contrast | Comparability Source | Quality | Risk |215|----------|---------------------|---------|------|216| {A vs B} | {mechanism} | Strong/Weak | {risk description} |217| {A vs Control} | {mechanism} | Strong/Weak | {risk description} |218219## Replication Summary220221| Condition | N (units) | N (replicates) | Randomization Unit | Analysis Unit | Pseudoreplication? |222|-----------|-----------|----------------|-------------------|---------------|-------------------|223| {Arm 1} | {n} | {r} | {unit} | {unit} | Yes/No |224| {Arm 2} | {n} | {r} | {unit} | {unit} | Yes/No |225```226227---228229## Pre-Diagram Checklist230231Before creating the diagram, verify:232233- [ ] LOADED `/mermaid` skill using the Skill tool234- [ ] Using ONLY classDef styles from the mermaid skill (no invented colors)235- [ ] Diagram will include a color legend table236237---238239## Related Skills240241- `/make-experiment-diag` - Parent skill for lens selection242- `/mermaid` - MUST BE LOADED before creating diagram243- `/exp-lens-causal-assumptions` - For causal structure analysis244- `/exp-lens-unit-interference` - For interference and spillover risks