Contents / Statistics / Design of Experiments
Chapter 6
Design of Experiments
Potential outcomes and why randomisation identifies a causal effect; control, blinding and placebo; blocking and the exact variance reduction it buys, including Latin squares; factorial designs and why varying one factor at a time is strictly worse; replication, pseudoreplication and sizing an experiment for power; and what can and cannot be recovered from observational data, including Simpson's paradox.
Introduction
The last two chapters analysed data. This one asks where the data came from, and it is the chapter that licenses the conclusions the others compute. A regression coefficient is an association; an ANOVA finds that group means differ. Neither says that changing the treatment would change the outcome, and no amount of arithmetic applied afterwards can supply that. What supplies it is how the data were generated.
The central problem is stated in one sentence: to know the effect of a treatment on a unit, you would need to observe that unit both treated and untreated, and you never can. Every method here is a way of manufacturing a substitute for the observation you cannot make. Randomisation does it by making the treated and untreated groups exchangeable in expectation, so that the untreated group is a valid stand-in for what the treated group would have done. That is the argument of the first section, and it is proved rather than asserted.
The remaining sections are about doing it efficiently. Blocking removes a known source of variation before randomising within it, and the variance reduction is exactly computable — it is the paired -test of the testing chapter, generalised. Factorial designs vary several factors at once, which sounds reckless and is in fact strictly better than varying one at a time: the same runs estimate every main effect and the interactions, at no cost in precision. And replication determines whether the experiment can detect the effect it was built to find, which is the power calculation of the testing chapter read as a design constraint.
The last section is about what to do when experimentation is impossible. Observational data can sometimes support causal claims, but only under assumptions that are not testable from the data, and Simpson's paradox is there to show how badly the naive approach fails.
Notation follows the ANOVA chapter. Facts about the -test, two-way decomposition and interaction are from Analysis of Variance, and the power calculation from Statistical Inference: Hypothesis Testing.
6.1Randomisation, and why it works
The problem has to be set up carefully, because the intuitive statement — "compare treated and untreated units" — is exactly what does not work.
Definition 6.1 (Potential outcomes and the treatment effect). For each unit , let be the outcome that would occur if it received the treatment and the outcome if it did not. The individual treatment effect is , and the average treatment effect is
With the treatment actually assigned, the observed outcome is .
Remark (The fundamental problem of causal inference). Exactly one of and is ever observed for a given unit; the other is counterfactual. So is not estimable for any individual, no matter how much data is collected on that individual.
The average is a different matter, and that is the opening the rest of this section exploits. It is a statement about a population, and a population contains units of both kinds.
The naive estimator compares the observed means of the two groups. Whether it works depends entirely on how was decided.
Theorem 6.2 (Randomisation identifies the average treatment effect). Suppose is assigned independently of the potential outcomes — formally , which randomisation guarantees by construction. Then the difference in group means is unbiased for :
Proof. Consider the treated group. By independence, conditioning on does not change the distribution of the potential outcomes:
the first equality because when , and the second by independence. Identically, .
The group means are averages of such observations, so
Everything turns on the independence assumption, and it is worth seeing exactly where it was used: in replacing by . That step says the units who happened to be treated are not systematically those who would have done better anyway. Randomisation makes it true by construction, because a coin flip cannot know anything about a unit. Nothing else makes it true automatically.
Intuition. Randomisation is not about being fair, and it is not about producing groups that are identical — with small samples they will differ visibly on any characteristic you care to check. Its job is narrower and stronger: it guarantees that any difference between the groups is accidental, so that the differences are governed by known probability and are exactly what a standard error measures.
That is why it handles confounders you never thought of. Matching on age, sex and income protects against those three; randomisation protects against every variable simultaneously, including ones nobody has named, because the assignment mechanism was independent of all of them at once.
Definition 6.3 (Control, blinding, and placebo). A control group receives no treatment or a standard one, supplying the comparison. A placebo is an inert treatment indistinguishable from the real one, so the control experiences the same procedure. A study is single-blind if the subjects do not know their assignment, and double-blind if those measuring the outcome do not either.
Blinding addresses a different failure from randomisation. Randomisation makes the groups comparable before treatment; blinding keeps them comparable afterwards, by ensuring that knowledge of the assignment does not itself change behaviour, reporting, or measurement. An unblinded trial can be perfectly randomised and still biased, because a clinician who knows the assignment may assess outcomes differently.
Pitfall. Randomisation licenses a causal claim about the population actually randomised, and nothing wider. A drug trial randomised among healthy adults aged 18 to 40 establishes an effect in healthy adults aged 18 to 40; extending it to the elderly is extrapolation of the same kind the regression chapter warned about, and the randomisation does not travel with it.
The distinction is between internal validity — the comparison inside the study is sound — and external validity — the result generalises. Randomisation buys the first outright and the second not at all.
Example 6.4 (Why a well-intentioned non-random assignment fails). A hospital offers a new surgical procedure and lets surgeons choose which patients receive it. Surgeons naturally select healthier patients as better candidates. The new procedure shows a success rate against for the standard one. What has been established?
Solution.
- Write the comparison in potential-outcome terms. The estimator is .
- For this to equal we would need and likewise for the control. Both fail: the treated patients are healthier, so they would have had better outcomes under either treatment.
- Decompose the observed gap by adding and subtracting :
- The second term is the difference in baseline health between the groups, and it is positive here by construction. The observed -point gap is the true effect plus that bias, and nothing in the data separates them.
- Sanity check on the direction: the bias inflates the apparent benefit, so the procedure could be genuinely worthless — or actively harmful — and still show a -point advantage if the selection is strong enough.
- Note that adjusting for measured health does not fix this. It removes the part of the selection captured by the variables recorded, leaving whatever the surgeons perceived and the records did not.
Example 6.5 (Randomising, and reading a balance table). Sixty patients are to be randomised between two treatments. Describe a valid procedure, and say what to do if the resulting groups differ noticeably in mean age.
Solution.
- Simple randomisation: for each patient independently, assign treatment with probability — a coin flip, or a random number below . This satisfies the independence hypothesis of the theorem Randomisation identifies the average treatment effect exactly.
- Its drawback is that group sizes vary: with the split has standard deviation , so a split is unremarkable and costs a little precision.
- Block randomisation fixes that: within each successive block of, say, patients, randomly permute two of each treatment. The groups stay nearly balanced throughout, and the assignment is still independent of the potential outcomes.
- On a chance imbalance in age: this is expected, not a failure. With many baseline variables measured, some will differ at any conventional threshold purely by chance — testing of them at gives about a chance of at least one "significant" imbalance, by the multiplicity arithmetic of the testing chapter.
- The correct response is not to re-randomise until the table looks balanced, which destroys the independence the whole argument rests on. If age is known to matter, it should have been a blocking variable; failing that, adjusting for it in the analysis is legitimate provided the decision is pre-specified.
- Sanity check on what randomisation promised: not balance, but that any imbalance is accidental and therefore already priced into the standard error. ✓
6.2Blocking: removing variation before it becomes noise
Randomisation makes the comparison valid. It does not make it precise, and with variable units a randomised comparison can be valid and useless. Blocking is the standard remedy.
Definition 6.6 (Randomised complete block design). Partition the experimental units into blocks of similar units, then randomise the treatments independently within each block, so every block contains every treatment. Block membership is a known nuisance factor, not a factor of interest.
Theorem 6.7 (Variance reduction from blocking). Suppose two treatments are compared on pairs of units, where units within a pair have outcomes correlated at , each with variance . The completely randomised comparison has
while the blocked (paired) comparison has
Blocking therefore multiplies the variance by .
Proof. In the unblocked design the two group means are computed from independent units, so their variances add: .
In the blocked design the comparison is made within pairs. For a single pair, and
The pairs are independent, so . Dividing the two expressions gives the factor .∎
The theorem prices the design decision exactly. Pairing units correlated at cuts the variance to a fifth, which is equivalent to quintupling the sample size — and it costs one degree of freedom per block rather than five times the budget. This is the paired -test of the testing chapter seen from the design side: the same arithmetic that made pairing more powerful there is a reason to build pairing into the experiment here.
Pitfall. Blocking is only worth doing on a variable genuinely related to the outcome. Blocking on an irrelevant variable gives , so the variance is unchanged, and the degrees of freedom spent on block effects are lost for nothing — the analysis becomes slightly less powerful.
And once you have blocked, you must analyse as blocked. Running an unpaired test on paired data throws the entire gain away and, as the testing chapter showed, is invalid besides.
Example 6.8 (Sizing a blocked experiment). Two fertilisers are compared across fields. Fields vary greatly in fertility, and adjacent half-fields correlate at . Compare splitting each field in two (blocked) against assigning whole fields at random (unblocked).
Solution.
- Unblocked, fields per treatment: .
- Blocked, splitting all fields so each contributes a pair: .
- The ratio is , an eight-fold reduction in variance — a factor of from doubling the number of comparisons and a factor of from the correlation.
- Equivalently, the unblocked design would need fields to match the blocked design's precision with .
- Sanity check on the mechanism: field fertility is a large source of variation that affects both halves of a field almost equally, so it cancels in the within-field difference. It never enters the standard error at all, which is what records.
- What blocking does not do: it does not make the comparison valid — the assignment within each field must still be randomised. Blocking improves precision; randomisation buys the causal claim.
Definition 6.10 (Latin square design). When two nuisance factors must be controlled, a Latin square arranges treatments in a grid whose rows index one nuisance factor and columns the other, so that every treatment appears exactly once in each row and each column.
Example 6.11 (Blocking on two nuisances at once). Four machine operators are to be compared on four machines across four days, with only runs available. Show how a Latin square allocates them, and count the degrees of freedom.
Solution.
- Index rows by day and columns by machine, and place the four operators so each appears once per row and once per column:
| Machine 1 | Machine 2 | Machine 3 | Machine 4 | |
|---|---|---|---|---|
| Day 1 | A | B | C | D |
| Day 2 | B | C | D | A |
| Day 3 | C | D | A | B |
| Day 4 | D | A | B | C |
- Every operator works on every machine and on every day, so any systematic day effect or machine effect is balanced equally across operators and cannot be confounded with the operator comparison.
- Degrees of freedom from runs: for the mean, each for days, machines and operators, leaving for error.
- Compare the cost of a full factorial: runs would be needed to cross all three factors, four times the budget.
- Sanity check on the price paid: with only error degrees of freedom the test is not powerful, and the design assumes no interactions among days, machines and operators — there are no runs left to estimate them. A Latin square buys efficiency by assuming additivity, and that assumption is not checkable within the design.
6.3Factorial designs
With several factors, the instinct is to study them one at a time, holding the others fixed — it feels careful and controlled. It is strictly worse, and the reason is worth understanding because it is counter-intuitive.
Definition 6.12 (Factorial design). A full factorial design runs every combination of the levels of every factor. With factors each at levels this is a design, requiring distinct runs, replicated times each.
Theorem 6.13 (Factorial designs estimate more from the same runs). Consider two factors and , each at two levels, with runs in total and error variance .
A one-factor-at-a-time experiment splitting runs between a baseline and a change in estimates the effect of with variance , and gives no information about or about interaction.
A factorial with runs per cell estimates the effect of with the same variance — and simultaneously estimates the effect of , and their interaction, to the same precision.
Proof. One factor at a time. With runs at each of two conditions, the estimate is a difference of two means each based on observations, so
Factorial. The main effect of is the mean of all runs at high minus the mean of all runs at low. Each of those averages over two cells, hence over runs, so
identical. The same computation applies to , whose two averages also each cover runs — because every run contributes to the estimate of both main effects, once through its level and once through its level. The interaction contrast, scaled appropriately, uses all runs likewise.∎
Intuition. The phrase for this is hidden replication. In a factorial design every observation is used in the estimate of every main effect, because averaging over the other factor's levels does not discard those runs — it pools them.
One-factor-at-a-time uses each run for one comparison only. That is the whole inefficiency, and it compounds: with factors, the factorial estimates all main effects at the precision that OFAT achieves for one, from the same total budget.
There is a second and larger advantage. A one-factor-at-a-time experiment cannot detect interaction at all — it never observes the combination where both factors are changed, so it has no data bearing on whether the effects add. If the factors interact, its conclusions about each factor are valid only at the baseline level of the other, which is usually not stated and often not true where it matters.
Proposition 6.14 (How many effects a two-level factorial estimates). A factorial estimates effects: main effects, two-factor interactions, three-factor interactions, and so on.
Proof. The effects correspond to the non-empty subsets of the factors — a subset of size is a main effect, of size a two-factor interaction, and so on. The number of non-empty subsets of a -element set is .
That this exhausts the available information is a dimension count: the design has distinct cells, so cell means, and they are reparametrised by an overall mean plus effects.∎
Example 6.15 (Three factors in eight runs). A chemical yield is studied at two levels each of temperature, pressure and catalyst. Compare the factorial with a one-factor-at-a-time study, both using runs.
Solution.
- Factorial. cells with runs each. By the theorem Factorial designs estimate more from the same runs, each main effect is a difference of two means over runs each, with variance .
- It estimates effects: main effects, two-factor interactions, and three-factor interaction.
- One factor at a time. With four conditions (baseline, plus one change each) and runs each, every main effect is a difference of two means over runs, with variance — twice the factorial's variance.
- So the factorial estimates each main effect with half the variance and returns four interaction effects that OFAT cannot estimate at all.
- Sanity check on the standard errors: against , a ratio of . To match the factorial, OFAT would need twice the runs and would still learn nothing about interaction.
- The practical consequence: if temperature and catalyst interact — a higher temperature helps only with the new catalyst — the OFAT study, having tested temperature at the old catalyst, reports that temperature does not matter. The factorial finds it.
Example 6.16 (Estimating effects from a 2-squared factorial). A experiment on yield gives cell means , , , , where the first index is the level of and the second of , with per cell and . Estimate the two main effects and the interaction, and test the interaction with .
Solution.
- Main effect of — the average change in yield when goes from low to high, averaged over :
- Main effect of , averaging over : .
- Interaction — half the difference between 's effect at the two levels of :
Equivalently , which is the same arithmetic. 4. Each of these is a contrast in four cell means with coefficients , so its variance is , giving a standard error of . 5. Interaction test: , so the interaction is significant. 's effect is genuinely larger when is high. 6. Sanity check on the reporting: because the interaction is significant, the main effect of — the single number — should not be quoted on its own. The honest statement is that raises yield by when is low and by when is high, which is exactly the pitfall from the ANOVA chapter applied to a designed experiment.□
6.4Replication and the size of an experiment
Definition 6.18 (Replication, repeated measurement, and pseudoreplication). Replication means applying a treatment independently to several experimental units. Repeated measurement means measuring the same unit several times. Pseudoreplication is treating repeated measurements as if they were replicates.
The distinction decides the sample size that enters every formula, and getting it wrong inflates the apparent precision dramatically. Ten plants in one growth chamber, measured individually, are ten measurements of one independently treated unit: the chamber is the experimental unit, because the treatment was applied to the chamber. The correct is the number of chambers.
Pitfall. Pseudoreplication is the most common serious error in experimental analysis, and it is invisible in the output — the software cannot know which units were independently assigned. Taking to be the number of measurements rather than the number of independently treated units divides the standard error by roughly for measurements per unit, so a study with chambers and plants each reports standard errors about times too small, and -values correspondingly too extreme.
The diagnostic question is always: what was randomised? Whatever unit the assignment was applied to is the experimental unit, and its count is .
Example 6.19 (Counting the experimental units). Four growth chambers are randomly assigned to two temperature settings, two chambers each. Each chamber holds plants, and every plant's height is recorded. A researcher analyses this as per group. What is the correct , and how wrong is the reported standard error?
Solution.
- The treatment was applied to chambers, not to plants: every plant in a chamber received the same setting, and no plant was independently assigned. So the experimental unit is the chamber and the correct is per group.
- Plants within a chamber share everything that chamber does — humidity, light, an accidental draught — so their outcomes are correlated, and correlated observations do not carry independent pieces of information.
- The reported standard error uses instead of , so it is too small by a factor of about .
- Consequently a statistic is about times too large, and a genuinely null result can be reported at .
- The correct analysis: average the plants within each chamber to a single number, then compare the four chamber means — a two-sample test with per group and degrees of freedom. That is a very weak experiment, which is the honest conclusion: four chambers cannot support much.
- Sanity check on the design fix: the remedy is more chambers, not more plants per chamber. Doubling the plants to each barely improves precision, since the chamber effect does not average away; doubling the chambers halves the variance of the comparison.
Theorem 6.20 (Replicates needed to detect an effect). To detect a difference between two treatment means with power in a two-sided level- test, with error standard deviation , the number of replicates per treatment is
Proof. The standard error of the difference of two means with replicates each is . By the corollary Sample size for a target power applied to that standard error, the requirement is
Rearranging, , and squaring gives the stated bound.∎
Example 6.21 (Sizing a two-treatment experiment, with and without blocking). An effect of units is worth detecting, with , at two-sided and power. Find the replicates required, then repeat assuming blocking with is available.
Solution.
- , so .
- Unblocked: , so replicates per treatment, units in total.
- Blocked: the effective error variance becomes , so , giving pairs — units in total.
- Blocking cuts the experiment from units to , a reduction of , which is exactly the factor applied to the variance.
- Sanity check on the effect size: is a small standardised effect, and small effects are expensive — halving it to would quadruple both numbers.
- Note what the calculation requires in advance: a value for and a decision about what size of effect matters. Neither comes from the data being collected, which is why these numbers must be settled before the experiment, not after.
6.5When you cannot randomise
Experiments are often impossible — for ethical reasons, for practical ones, or because the exposure of interest cannot be assigned. The analysis then rests on assumptions rather than on design, and it is important to be precise about which.
Definition 6.22 (Observational study and confounding). In an observational study the investigator observes treatment assignment rather than controlling it. A confounder is a variable associated with both the treatment and the outcome, and not on the causal pathway between them.
Theorem 6.23 (Adjustment identifies the effect only under no unmeasured confounding). Suppose treatment is independent of the potential outcomes given a set of measured covariates — the assumption of no unmeasured confounding:
Then the average treatment effect is identified by adjustment:
Proof. Within a stratum of , the conditional independence is exactly the hypothesis of the theorem Randomisation identifies the average treatment effect, so that theorem applies stratum by stratum:
Averaging over the distribution of and using the tower property gives .∎
The theorem is true and its hypothesis is untestable. Nothing in the data reveals whether an unmeasured confounder exists, because by definition it was not measured. This is the fundamental asymmetry: a randomised experiment earns its assumption by construction, while an observational study assumes it and cannot check it.
Example 6.24 (Simpson's paradox). Two treatments for kidney stones give these success rates:
| Small stones | Large stones | Overall | |
|---|---|---|---|
| Treatment A | |||
| Treatment B |
Treatment A is better for small stones and better for large stones, yet worse overall. Which treatment should a patient choose?
Solution.
- The arithmetic is correct: out of , and out of . Both column pairs and the totals are accurate.
- The reversal comes from the allocation. Treatment A was given mostly to large stones ( of , or ), which have a worse prognosis under either treatment; treatment B was given mostly to small stones ( of , or ).
- So A's overall rate is dragged down by the difficulty of the cases it took, not by any deficiency of the treatment. Stone size is a confounder: it affects both the treatment assigned and the outcome.
- Treatment A is the right choice. Any patient has either a small stone or a large one, and A is better in both cases. The overall figures answer a question no patient faces — "what is the success rate of a treatment given to this particular mix of cases?" — and that mix is an artefact of how doctors assigned treatments.
- Sanity check by re-weighting: if both treatments had been given to the same case mix, say , then A would achieve and B . The reversal disappears and A is ahead by five points.
- The general lesson is uncomfortable: the aggregated table and the stratified table give opposite answers, and only knowledge of the causal structure decides which to believe. Here stone size influences treatment choice and outcome, so it must be conditioned on. Had the third variable instead been a consequence of treatment, conditioning on it would have been the error.
Example 6.26 (Adjusting by stratification). Using the kidney-stone table, compute the treatment effect adjusted for stone size by weighting each stratum by its share of all patients.
Solution.
- Stratum sizes across both treatments: small stones ; large stones ; total .
- Weights: for small, for large.
- Adjusted rate for A: .
- Adjusted rate for B: .
- The adjusted difference is , so A is about percentage points better — the reversal is gone, and the direction now agrees with both strata.
- Sanity check against the unadjusted comparison, which had B ahead by . Adjustment has moved the estimate by nearly percentage points and flipped its sign, which is the size of the confounding by stone size.
- The caveat from the theorem Adjustment identifies the effect only under no unmeasured confounding applies in full: this number is the causal effect only if stone size is the sole confounder. Nothing in the table can confirm that.
Remark (Designs that recover some of what randomisation gives). Several strategies exploit sources of near-random variation.
A natural experiment uses an external event — a policy change, a lottery, a threshold — that assigned exposure in a way plausibly unrelated to the outcomes. A regression discontinuity compares units just above and just below a cut-off for eligibility, where assignment is nearly arbitrary. An instrumental variable is a factor influencing treatment but affecting the outcome only through it, which allows an effect to be recovered even with unmeasured confounding.
Each replaces "no unmeasured confounding" with a different assumption, not with no assumption at all. They are better than naive adjustment because their assumptions are sometimes defensible from knowledge of how the world works, rather than from a hope that everything relevant was recorded.
Pitfall. Adding more covariates to an adjustment is not uniformly safer. Conditioning on a variable that lies on the causal pathway from treatment to outcome removes part of the very effect being estimated. Conditioning on a collider — a variable caused by both the treatment and the outcome — creates an association where none existed.
So the choice of what to adjust for is a causal question that must be answered before the data are analysed, using knowledge of the subject matter. It is not a statistical question, and "control for everything available" is not a safe default.
- Treating an association from observational data as an effect. Without randomisation, the comparison contains a selection term that the data cannot separate from the effect.
- Believing randomisation makes the groups identical. It makes any difference accidental, which is what standard errors are built to measure — a much more useful guarantee than similarity.
- Extending a randomised result beyond the population randomised. Internal validity does not imply external validity.
- Blocking and then analysing as unblocked. The entire precision gain is discarded, and the analysis is invalid besides.
- Blocking on a variable unrelated to the outcome. With there is no variance reduction and the block degrees of freedom are wasted.
- Studying one factor at a time. A factorial gets every main effect at the same precision from the same budget, plus the interactions that OFAT cannot detect at all.
- Pseudoreplication. The experimental unit is whatever the treatment was randomised to; repeated measurements of one unit are not replicates.
- Deciding the sample size after seeing the data. The power calculation needs and a meaningful effect size fixed in advance.
- Adjusting for everything measured. Conditioning on a mediator removes part of the effect; conditioning on a collider manufactures an association.