Design the logic for cleaning an experiment’s data, one decision at a time. No code required.
What counts as correctWhat this exercise assumes
The toy datasets (X, Y and the canonical one) are invented for the exercise.
The larger population is simulated: 100 households of 1 to 6 people, mostly 2 to 4, 336 people in all, from a fixed seed.
Under individual randomization, each person is treated independently with probability p. Under household randomization, each household is treated with probability p and everyone in it shares that status.
Baseline income (thousand pesos per month) is simulated to fall by about 1.6 for each extra household member, plus noise. It plays no part in any cleaning rule; it is only used to check balance.
No outcomes, treatment effects or spillovers are simulated.
Left out on purpose: estimating treatment effects, modelling spillovers, standard errors and power. R appears only as a display of the logic you design.