Factorial designs and interaction: testing two things at once
If a drug lowers blood pressure and exercise lowers it too, does doing both lower it by the sum of the two? It might lower it more, or less. Drag the four cell means yourself and see, in numbers and in a picture, what it means for the effect of one factor to depend on another.
Short answer. A factorial design is a design that tests every combination when there are two or more things you want to learn about (factors). If the factors are "give drug A or not" and "exercise or not", you test all four combinations: neither, drug A only, exercise only, both. It finds the effect of each factor (the main effects) with fewer runs than changing one thing at a time, and it is the only way to see whether the effect of one factor depends on the other (the interaction). In a 2×2 design the interaction is (y₁₁ − y₀₁) − (y₁₀ − y₀₀): the drug effect with exercise minus the drug effect without exercise.
no exerciseexerciseif the effects just addinteraction
| no drug A | drug A | |
|---|---|---|
| exercise | ||
| no exercise |
| Main effect of drug A | ||
|---|---|---|
| Main effect of exercise B | ||
| Interaction (difference of differences) |
Drag the four points up and down, or edit the numbers on the right (0 to 20). Across is no drug A or drug A. Up is the mean drop in systolic blood pressure after 8 weeks, in mmHg, for each cell. The green line joins the two cells without exercise and the blue line joins the two cells with exercise. The purple dashed line is where the blue line would be "if the effects just added" (parallel to the green line), and the orange bar is the gap to the real value: the interaction. The bars below run from −40 to 40. Every number and every data point on this page is made up and says nothing about real drugs or exercise. This page explains a statistics idea.
Definitions
The text below uses a 2×2 factorial design: two factors with two levels each. In a 2×2 design, is the mean response of the treatment combination made of level i of factor A and level j of factor B (0 or 1).
- factor, level
- A factor is a variable whose values the experimenter sets in order to study its effect on the response. Each value a factor takes in the experiment is a level. For a factor with two levels, the low and high levels are written as 0 and 1 (or −1 and +1).
- treatment combination, factorial design
- One level chosen for each factor makes a treatment combination. When k factors have levels, a (full) factorial design tests every treatment combination. The number of combinations is shown below. When every factor has two levels it is (a factorial design).
- main effect
- The main effect of a two-level factor is the mean of the treatment combinations at its high level minus the mean of the treatment combinations at its low level. It is the effect averaged over the levels of the other factors. In a 2×2 design:
- simple effect
- The effect of one factor while another factor is held at one level. In a 2×2 design the simple effect of A with B held at level j is shown on the left below. The main effect of A is the average of the two simple effects.
- interaction
- Two factors interact when the simple effect of one factor differs across the levels of the other. In a 2×2 design this page uses the difference of the two simple effects (the difference of differences) as the interaction effect. It is 0 when there is no interaction. Books that compute effects from a sign table use half of this value (section 3).
- contrast
- A linear combination of the treatment means whose coefficients add up to 0. In a 2×2 design, with the cells in the order (y₀₀, y₁₀, y₀₁, y₁₁), the coefficients are (−1, +1, −1, +1) for A, (−1, −1, +1, +1) for B, and their cell-by-cell product (+1, −1, −1, +1) for AB. The main effects of A and B are their contrasts divided by 2, and the difference of differences is the AB contrast itself.
1. Factors, levels and treatment combinations
In an experiment, a factor is something the experimenter sets because they want to know if it changes the result. Giving a drug or not, exercising or not, the temperature of a culture, the amount of fertilizer. The values a factor can take are its levels. "Drug A: no or yes" has two levels. "Dose: 0, 10 or 20 mg" has three.
Pick one level of each factor and you get a treatment combination (a cell). A factorial design tests all of the combinations. Two factors with two levels each give 2 × 2 = 4 cells, which is called a 2×2 factorial design. The example on this page looks like this (made up).
| no drug A | drug A | |
|---|---|---|
| exercise | y₀₁: exercise only | y₁₁: both |
| no exercise | y₀₀: neither | y₁₀: drug A only |
The first small digit under y is drug A (0 no, 1 yes) and the second is exercise (0 no, 1 yes). The result is the drop in systolic blood pressure after 8 weeks, in mmHg, and each cell holds the mean of the people in that cell. Each person is put into one of the four cells at random. That is what lets you say a difference between cells comes from the treatments.
Effects come in three kinds.
- Main effect: how much the result changes on average when you change one factor, averaged half and half over the two levels of the other factor. Main effect of drug A = mean of the two cells with the drug − mean of the two cells without it.
- Simple effect: the effect measured while the other factor is held at one level. The effect of drug A among people who do not exercise is
y₁₀ − y₀₀, and among people who do it isy₁₁ − y₀₁. - Interaction: the simple effects differ depending on the level of the other factor. It is measured as the difference between the two simple effects,
(y₁₁ − y₀₁) − (y₁₀ − y₀₀). If it is 0, there is no interaction.
2. How to read an interaction plot
The picture in the lab above is called an interaction plot. Put the levels of one factor across, draw one line for each level of the other factor, and plot the cell means up the side. There is one thing to check: are the lines parallel?
| Lines | Meaning | In the lab |
|---|---|---|
| parallel | No interaction. Drug A has the same effect with or without exercise. The two effects just add | "Just add" |
| spread apart or come together | There is an interaction. Same direction, different size (a quantitative interaction) | Starting values, "Only together", "Get in each other's way" |
| cross | Even the direction flips (a qualitative interaction). It raises the result in one group and lowers it in the other | "Crossing" |
- The slope of a line is the simple effect of the factor across, in that line's group. The slope of the green line is the effect of drug A without exercise.
- The vertical gap between the lines is the simple effect of the line factor. The gap at the left end is the effect of exercise without the drug.
- Swap the factors (put exercise across) and the size of the interaction stays the same (step ⑤ in section 3). But whether the lines cross can depend on which factor you put across. Draw it both ways.
- The points are means. Real data wobbles, so lines that are a little apart may be chance. Section 6 checks that with an analysis of variance.
Try this. ① With the starting values (2, 8, 6, 16) the main effect of drug A is 8, the main effect of exercise is 6, and the interaction is 4. The purple point sits at 12 and the real y₁₁ at 16. ② Drag the top right point (y₁₁) down to 12. The blue line lands on the purple dashed line and the interaction becomes 0. The main effects change to 6 and 4. ③ "Only together" (2, 2, 2, 12): drug A alone and exercise alone do nothing, but both together lower blood pressure by 10 more. The main effects are 5 and 5, and the interaction is 10. ④ "Get in each other's way" (2, 10, 8, 12) has an interaction of −4. The cell with both is 12, which is 4 less than the 16 you would expect from adding the separate effects. ⑤ "Crossing" (4, 10, 10, 4) has both main effects at 0 but an interaction of −12. Drug A lowers blood pressure by 6 more in people who do not exercise and by 6 less in people who do. "Drug A has no effect" is wrong for both groups.
3. How the formula is built: from four cells to three effects
Let's pull the three effects (main effect of drug A, main effect of exercise, interaction) out of the four cell means one at a time. The pictures use the four means from the lab above. Move a point up there and this changes too.
| Cell | Mean | A sign | B sign | AB sign |
|---|
Press "Next" to go one step at a time. A line is added to the formula (the orange background marks the new line), the square and the interaction plot change to match, and the reason appears below. At the last step a sign table appears at the very bottom.
Written as formulas only, the steps above look like this (starting values 2, 8, 6, 16).
- The four cells on the corners of a square. y₀₀ = 2 (bottom left), y₁₀ = 8 (bottom right), y₀₁ = 6 (top left), y₁₁ = 16 (top right). Each side of the square is "two cells that differ in one factor only". The bottom side changes the drug while nobody exercises.
- Effect of A: right side minus left side.
A = (y₁₀ + y₁₁) ÷ 2 − (y₀₀ + y₀₁) ÷ 2 = (8 + 16) ÷ 2 − (2 + 6) ÷ 2 = 12 − 4 = 8. Why: the right side and the left side each have one cell with exercise and one without. So when you subtract, the exercise part cancels and only drug A's part is left. It is also the average of the two simple effects, 6 and 10. - Effect of B: top side minus bottom side.
B = (y₀₁ + y₁₁) ÷ 2 − (y₀₀ + y₁₀) ÷ 2 = 11 − 5 = 6. Why: same idea. All four cells were used for the effect of A and again for the effect of B. Each person's data answers both questions (hidden replication, section 9). - If the effects just add.
expected y₁₁ = y₀₀ + (y₁₀ − y₀₀) + (y₀₁ − y₀₀) = 2 + 6 + 4 = 12. Start from the cell with neither and add what drug A alone added and what exercise alone added. The purple point on the right is this guess, on a purple dashed line parallel to the green line. Why: this is the idea "the two effects add up without affecting each other", built from the other three cells before looking at y₁₁. Do not add the main effects 8 and 6 here.2 + 8 + 6 = 16matches the real y₁₁ for any data at all, because the main effects already used y₁₁. - Interaction: actual minus expected.
AB = y₁₁ − expected = 16 − 12 = 4. Put the expected value in and rearrange:y₁₁ − y₁₀ − y₀₁ + y₀₀ = (y₁₁ − y₀₁) − (y₁₀ − y₀₀) = 10 − 6 = 4. That is the effect of drug A with exercise (10) minus its effect without exercise (6): a difference of differences. Group the same terms as(y₁₁ − y₁₀) − (y₀₁ − y₀₀) = 8 − 4 = 4and it reads "the effect of exercise with the drug minus without the drug". The interaction is symmetric in the two factors, so there is only one number. - Sum it up in a sign table. Give each cell a + or a − and add them up, and all three effects come out at once. For A, the cells with the drug get +. For B, the cells with exercise get +. The sign for AB is A's sign times B's sign.
| Cell | Mean | A | B | AB = A × B |
|---|---|---|---|---|
| y₀₀ neither | 2 | − | − | + |
| y₁₀ drug A only | 8 | + | − | − |
| y₀₁ exercise only | 6 | − | + | − |
| y₁₁ both | 16 | + | + | + |
| sum of sign × mean | 16 | 12 | 4 | |
| effect | 16 ÷ 2 = 8 | 12 ÷ 2 = 6 | 4 |
A and B are "mean of two cells minus mean of two cells", so their sums are divided by 2. For AB the sum itself is the difference of differences. Some books divide AB by 2 as well. Books and handbooks that compute effects from a sign table, such as Box, Hunter and Hunter and the NIST handbook, write all three effects as "mean of the + cells minus mean of the − cells". Then the interaction is (2 + 16) ÷ 2 − (8 + 6) ÷ 2 = 9 − 7 = 2, half the difference of differences. It is the same thing on a different scale, so check which one a number uses (the table in section 4).
Try this. ① Press "Next" five times and check that the sign table at the last step shows A 16 ÷ 2 = 8, B 12 ÷ 2 = 6, AB 4. ② In the lab above, press "Just add", then look at steps ④ and ⑤. The purple point sits on the real y₁₁ (expected 12, actual 12) and the interaction is 0. ③ Press "Crossing" and look at step ②. The right side and the left side both average 7, so the effect of A is 0. Yet at step ⑤ the interaction is actual 4 − expected 16 = −12.
4. Work it out by hand
Using the cell means 2, 8, 6, 16, here are the three effects and the same things written in other ways.
| What | Formula | Value |
|---|---|---|
| effect of drug A without exercise | y₁₀ − y₀₀ = 8 − 2 | 6 |
| effect of drug A with exercise | y₁₁ − y₀₁ = 16 − 6 | 10 |
| main effect of drug A | (6 + 10) ÷ 2, which is (8 + 16) ÷ 2 − (2 + 6) ÷ 2 | 8 |
| effect of exercise without the drug | y₀₁ − y₀₀ = 6 − 2 | 4 |
| effect of exercise with the drug | y₁₁ − y₁₀ = 16 − 8 | 8 |
| main effect of exercise | (4 + 8) ÷ 2 | 6 |
| interaction (difference of differences) | 10 − 6 or 8 − 4 | 4 |
| interaction (sign-table effect, half) | 4 ÷ 2 | 2 |
A main effect is the average of the two simple effects. So when the interaction is not 0, the main effect of 8 differs from the real effect in either group (6 or 10).
As a regression equation
The same four cells can be written as one regression equation. The coefficients depend on whether you code the factors as 0 and 1 or as −1 and +1.
| Coding | Equation | Interaction coefficient |
|---|---|---|
| 0 and 1 (a = 1 means drug A, b = 1 means exercise) | y = 2 + 6·a + 4·b + 4·a·b | 4: the difference of differences itself |
| −1 and +1 | y = 8 + 4·x_A + 3·x_B + 1·x_A·x_B | 1: a quarter of the difference of differences |
Put a = b = 1 in and you get 2 + 6 + 4 + 4 = 16. Put x_A = x_B = −1 in and you get 8 − 4 − 3 + 1 = 2. Both equations fit all four cells. A common misreading: in the 0 and 1 equation, the coefficient 6 on a is not the main effect of drug A. It is the simple effect without exercise (b = 0). People often make this mistake when they read a regression output that includes an interaction term.
With people in each cell: an analysis of variance by hand
Say each cell has two people. Neither: 1, 3. Drug A only: 7, 9. Exercise only: 5, 7. Both: 15, 17. The cell means are the same 2, 8, 6, 16, and the overall mean is 8. We follow the formulas from section 6.
- Total sum of squares. Square each value's distance from the overall mean 8 and add. The distances are −7, −5, −1, 1, −3, −1, 7, 9, so
49 + 25 + 1 + 1 + 9 + 1 + 49 + 81 = 216. - Leftover (within-cell) sum of squares. Each value's distance from its own cell mean. Each cell gives 1² + 1² = 2, so
2 × 4 = 8. - Sum of squares for drug A. The four people with the drug average 12 and the four without average 4, each 4 away from the overall mean.
4 × 4² + 4 × 4² = 128. In a 2×2 design this also equalsn × (main effect)² = 2 × 8² = 128. - Sum of squares for exercise.
n × (main effect)² = 2 × 6² = 72. - Sum of squares for the interaction.
n × (difference of differences)² ÷ 4 = 2 × 4² ÷ 4 = 8. - Check.
128 + 72 + 8 + 8 = 216. The four parts add up exactly to the total. - F. For each part, divide the sum of squares by its degrees of freedom (the mean square) and then by the leftover mean square,
8 ÷ 4 = 2. Drug A: 128 ÷ 2 = 64. Exercise: 72 ÷ 2 = 36. Interaction: 8 ÷ 2 = 4. - p. The chance of an F bigger than that, from the F distribution with (1, 4) degrees of freedom: drug A 0.0013, exercise 0.0039, interaction 0.116.
The same working as formulas is below. SS is a sum of squares, y is one person's value, is the overall mean, is the mean of that person's cell, and n = 2 is the number of people per cell.
The interaction is the same 4 as in the example, but its p-value is 0.116. In the same data the main effects of 8 and 6 came out clearly. Two people per cell are not enough to pick out an interaction of this size (section 8).
5. Key properties
| Property | In plain words | Where to see it |
|---|---|---|
| The interaction is symmetric | A's effect depends on B exactly as much as B's effect depends on A. There is one number | Step ⑤ in section 3: 10 − 6 = 8 − 4 |
| No interaction means main effect = simple effect | With parallel lines, "the effect of drug A" is one number | "Just add" |
| A main effect is an average | With an interaction, the main effect is only the average of the two simple effects and may match no group | The main effect of 0 in "Crossing" |
| The three effects do not overlap | With equal cell sizes the three columns of the sign table are orthogonal, so the sums of squares split cleanly and add up to the total | The ANOVA table in section 6 |
| The interaction depends on the scale | An interaction on the plain (additive) scale can disappear on a log scale, or appear there. Crossing lines stay crossed on any scale | Section 10 |
| Interaction estimates wobble more | With the same number of people, the standard error of the difference of differences is twice that of a main effect | Section 8 |
6. Check it with data: two-way ANOVA
In a real experiment each cell has many people, and each person's value wobbles. Cell means that are a little apart do not prove an interaction. A two-way analysis of variance (ANOVA) splits the total spread of everyone's values (the sum of squares) into four parts and asks whether each part is bigger than chance would explain. It is the one-factor analysis of variance extended to two factors.
total = Σ (value − overall mean)²
drug A = 2n × Σ (mean at a drug A level − overall mean)² summed over the two levels
exercise = 2n × Σ (mean at an exercise level − overall mean)²
A × B = n × Σ (cell mean − drug A level mean − exercise level mean + overall mean)² over the four cells
leftover = Σ (value − its own cell mean)²
total = drug A + exercise + A × B + leftover when every cell has the same number of people
F = (sum of squares of the part ÷ its df) ÷ (leftover sum of squares ÷ leftover df)
Σ: add up everything in the brackets.n: the number of people per cell.total: how widely everyone's values are spread (the sum of squares).drug A,exercise: the part from each of the two factors.A × B: the part from the interaction.leftover: how much people in the same cell wobble.F: whether a part is bigger than chance would explain.
n is the number of people per cell. Drug A, exercise and the interaction each have 1 degree of freedom, and the leftover has 4(n − 1). The p-value means the same as in hypothesis testing: the chance of an F this large if that effect were zero. The script on this page computes the areas under the F distribution itself (with the incomplete beta function).
no exercise (one person)exercise (one person)cell meantrue value (from the first lab)
| Source of spread | Sum of squares | df | Mean square | F | p |
|---|
Each dot is one person (made-up data). The true value of each cell is the matching mean from the first lab (purple diamond), and each person wobbles around it by the standard deviation, drawn with a fixed-seed random number generator. The black bars are the cell means from the data. Move a point in the first lab and the true value moves, and the data moves with it. "Draw new data" draws new people with the same true values. "Starting data" goes back to the first seed, a standard deviation of 6 and 10 people per cell. "Run it 1,000 times" draws new people 1,000 times with the current settings and counts how often each effect gives p < 0.05 (it always uses the same seeds, so it gives the same answer).
Try this. Keep the first lab at its starting values (2, 8, 6, 16). ① With the starting data (standard deviation 6, 10 people per cell) the cell means are −0.9, 8.51, 3.57, 16.55 and the difference of differences is 3.57. Drug A has F = 39.41 (p < 0.001) and exercise F = 12.3 (p = 0.001), both significant, but the interaction has F = 1, p = 0.324. The true interaction of 4 is there and was missed. ② Raise the number of people to 40. The interaction is caught with F = 4.7, p = 0.032, and the orange warning appears. ③ Press "Run it 1,000 times". With 10 people per cell, p < 0.05 came up for drug A 98.1%, exercise 87.3% and the interaction only 14.8% of the time. With 40 people the interaction reaches 54.3%, and with 60 people 72.6%. ④ Go back with "Starting data" and press "Draw new data" twice. Now the interaction is significant with F = 13.33, p < 0.001, and the difference of differences is 10.08, more than twice the true 4. When an effect has a low chance of being caught, the times it does get caught tend to overstate it. ⑤ In the first lab, press "Just add" and run it 1,000 times with 10 people per cell. The interaction comes up 5.1% of the time, about the 5% significance level. That is how often chance alone flags an interaction that is not there.
Common misreadings
- "The interaction p-value is above 0.05, so there is no interaction." Wrong. It means this data does not have enough evidence to tell. As in ① above, a real interaction is often missed. Look at the size of the interaction and its confidence interval too.
- "The p-value is small, so the effect is big." Wrong. With many people even a small effect gets a small p-value. Report the size of the effect separately, as a difference in cell means.
- Stopping at "drug A works, p < 0.001". If there is an interaction, that sentence only means "on average, with half the people exercising and half not" (section 7).
When cells have different numbers of people, the sums of squares no longer split this cleanly. The table then depends on the order in which you split them (what books call type I, II and III sums of squares). The lab on this page keeps all cells the same size.
7. How to report main effects when there is an interaction
A main effect is an average over the two levels of the other factor. When there is an interaction, that average is not the real effect in any group. In the example, the main effect of drug A, 8, is neither the 10 for people who exercise nor the 6 for people who do not.
- Look at the interaction first. Draw the interaction plot and look at the size of the interaction and its confidence interval.
- If there is one, report the effect at each level. "In people who did not exercise, drug A lowered blood pressure by 6 mmHg more. In people who did, by 10 mmHg more."
- If you report a main effect, add the condition. "On average 8 mmHg, in this experiment with half the people exercising." The average depends on the mix of levels in the experiment (here half and half). In a group where 30% of people exercise, the average effect would be
0.7 × 6 + 0.3 × 10 = 7.2. - If the lines cross, do not report a single main-effect number. In "Crossing" the main effect of drug A is 0, but "drug A has no effect" is wrong for both groups.
If you measure the effect in many groups and then pick a few to compare, you run into the multiple comparisons problem. Decide what to compare before you look at the data.
8. Finding an interaction takes many more people
Each cell mean wobbles by σ ÷ √n (its standard error), where σ is how much people differ from each other. When you add or subtract the means of four different cells, their variances (wobble squared) add up.
- Main effect = (sum of two cells − sum of two cells) ÷ 2. Its variance is
4 × σ²/n ÷ 2² = σ²/n, so its standard error isσ ÷ √n. - Interaction (difference of differences) adds and subtracts four cells and does not divide. Its variance is
4 × σ²/n, so its standard error is2σ ÷ √n: twice that of a main effect.
Cutting a standard error in half takes four times as many people. So catching an interaction the same size as a main effect, just as reliably, takes 4 times the people, and if the interaction is half the size of the main effect it takes 16 times. Factorial experiments are often planned on the assumption that interactions are smaller than main effects, but that is not always true, so decide on the size of interaction you want to find when you plan. In section 6, "Run it 1,000 times" with 10 people per cell caught drug A (main effect 8) 98.1% of the time but the interaction (difference of differences 4) only 14.8%.
If the interaction is what you are after, work out the sample size for the size of the interaction. With a sample size set for the main effects the power is low, the interaction is easy to miss, and an interaction that does come out significant by luck tends to be inflated (try this ④ in section 6).
9. One factor at a time versus a factorial design
A one-factor-at-a-time experiment keeps one starting combination (neither) and, for each factor, tests the combination where only that factor is changed. With two factors that is three combinations: neither, drug A only, exercise only. It looks at three corners of the square and never tests the cell with both (y₁₁).
- It cannot see the interaction. The interaction is how far y₁₁ is from the expected value, and there is no y₁₁.
- It measures something else. Its "effect of drug A" is only the simple effect without exercise (y₁₀ − y₀₀). With an interaction, that may not hold for people who exercise.
- It is less precise for the same number of runs. In a factorial design every person is used for the effect of drug A and again for the effect of exercise. Fisher (1935) called this hidden replication. One-factor-at-a-time uses only the people in the starting combination and the drug-only combination for the effect of drug A.
The lab below gives both methods the same number of runs. The number is (k + 1) × 2^k, so that it divides evenly over the combinations of both methods.
| Using the same runs | one factor at a time | factorial design |
|---|---|---|
| Combinations tested | ||
| Runs per combination | ||
| Runs used for the effect of one factor | ||
| Wobble of that effect (standard error, times σ) | ||
| Interactions it can see (of which two-factor) | 0 | () |
The left side is one factor at a time and the right side is the factorial design. Filled dots are combinations that are tested and empty dots are not. The number next to a dot is how many runs that combination gets. Two factors make a square and three make a cube. From four factors on, the combinations are laid out as a grid of dots. The wobble is the standard error when the spread between people, σ, is 1.
Try this. ① Two factors: with the same 12 runs, one-factor-at-a-time does 3 combinations 4 times each and the factorial design does 4 combinations 3 times each. For the effect of drug A, one-factor-at-a-time uses 8 runs (4 against 4) and the factorial design uses all 12 (6 against 6), so the wobble is σ × 0.71 against σ × 0.58. One-factor-at-a-time needs 1.5 times as many runs to wobble as little. ② Three factors: 8 combinations, the same 32 runs, wobble 0.5 against 0.35, 2 times as many runs needed. Only the factorial design sees the 4 interactions (3 between two factors, 1 among all three). ③ Six factors: 64 combinations, 3.5 times as many runs needed, 57 interactions it can see (15 of them between two factors). With three levels per factor there would be 3^6 = 729 combinations.
Here is why. Using the same N runs, the factorial design measures the effect of one factor as N/2 runs against N/2 runs, and one-factor-at-a-time as N/(k + 1) runs against N/(k + 1) runs. The variance goes down in proportion to the number of runs, so to reach the same precision one-factor-at-a-time needs (N/2) ÷ (N/(k + 1)) = (k + 1) ÷ 2 times as many runs. The gap grows with the number of factors. Fisher (1935) added a third advantage to these two (more precision for the same runs, and seeing interactions): because the other factors were varied, the conclusions hold over a wider range of conditions. A conclusion from an experiment where every other condition was held fixed has only been checked under that one condition.
Too many combinations: fractional factorial designs
With k factors at only two levels each there are 2^k combinations: 64 for 6 factors, 1,024 for 10. The NIST handbook does not recommend running every combination for 5 or more factors. The usual answer is a fractional factorial design, which tests a well-chosen part (a half, a quarter, and so on) of the combinations. In exchange, some effects get mixed up and cannot be told apart (aliasing). For example, in the common design that runs half of the combinations for 4 factors (8 runs), each main effect comes out as the same number as a three-factor interaction. You accept that because you assume interactions of three or more factors are small. Choosing which part to run is the heart of the design, and chapter 6 of Box, Hunter and Hunter covers it.
10. An interaction that comes and goes with the scale
Think of the number of cells in a culture dish (made-up data). With nothing added there are 100 cells. Adding substance A doubles that to 200, and adding substance B triples it to 300. If the two ratios simply multiply when both are added, you get 100 × 2 × 3 = 600. Each substance did its own job without affecting the other. Yet on the plain scale the interaction is (600 − 300) − (200 − 100) = 200.
no substance Bsubstance Bparallel to the green lineinteraction
Switch between "Plain scale" and "Log scale". The points slide to their places on the new scale. The sliders and number boxes set the cell count with substance A only and with substance B only (100 to 400). The cell with both follows the rule of the chosen data: for data that multiplies, both = A only × B only ÷ 100, and for data that adds, both = A only + B only − 100.
On a log scale, equal distances mean equal ratios. 100 to 200 and 300 to 600 are the same length (both double), so the lines become parallel. Take the difference of differences of the logged values and you get log 600 − log 300 − log 200 + log 100 = log(600 × 100 ÷ (300 × 200)) = log 1 = 0. So "there is an interaction" always needs "on which scale". An ANOVA or regression on the raw result looks at interaction on the additive scale.
- It also works the other way. "Data that adds" (100, 200, 300, 400) has parallel lines on the plain scale, but an interaction of −0.176 on the log scale.
- Crossing lines survive any change of scale. The order flips, and a change of scale that keeps the order (log, square root) cannot undo that.
- Analyses of ratios work on a multiplicative scale. An interaction in logistic regression or in odds ratios is an interaction on the log-odds scale, so the same data can give a different answer when you look at differences in risk.
- Chapter 8 of Box, Hunter and Hunter (Factorial Designs and Data Transformation) is about changing the scale to make the model simpler. Do not pick the scale you like after seeing the data. Think first about what is natural for the thing you measure (does it add, or does it multiply).
Try this. ① At the start (data that multiplies, plain scale) the cells are 100, 200, 300, 600 and the interaction is 200. Press "Log scale": the lines become parallel and the difference of differences on the log scale is 0. ② Press "Data that adds": the cells become 100, 200, 300, 400, with an interaction of 0 on the plain scale and −0.176 on the log scale. ③ With data that multiplies, lower "A only" to 100 (substance A does nothing). The interaction is 0 on both scales.
11. Subgroup analysis and interaction
Asking in a clinical trial "does this drug work better for women, or for older people?" is called subgroup analysis. It is the same as asking about a "drug × sex" interaction: you treat sex like a factor and draw a 2×2 table. But sex is not set by the experimenter. It is something people already have, so it is not assigned at random. Even if an interaction shows up, it may come from something else that goes along with sex, not from sex itself.
A common misreading: "p = 0.01 in men and p = 0.30 in women, so the drug works only in men." One group being significant and the other not is not evidence that the two effects differ. As the title of a paper by Gelman and Stern (2006) puts it, the difference between "significant" and "not significant" is not itself statistically significant. To see whether the effects differ between groups, test the interaction directly.
Split the data into enough subgroups and a "special group" will show up by chance. Even if the effect is truly the same in every group, testing 20 "drug × group" interactions at α = 0.05 gives on average 1 significant result by chance. So decide on a few subgroups before the trial, and report any others only as ideas to check in a later trial (multiple comparisons, clinical trial design).
12. Blocks are not factors
If an experiment runs at several hospitals or on several days, the result can shift from hospital to hospital or from day to day. Grouping the experimental units by something like this, which you do not care about but which moves the result, gives blocks (block designs). A block takes a row in the analysis table just like a factor, but it plays a different role.
| Factor | Block | |
|---|---|---|
| Why include it | You want to know its effect | To remove its spread so the treatment comparisons are more precise |
| Who sets it | The experimenter sets the levels and assigns them at random | It is already fixed (hospital, day, batch of dishes). It cannot be assigned at random |
| Interaction | Interactions between factors are what you look for | Usually assumed to have no block × treatment interaction |
| Conclusion | "The effect of drug A is 8" | "Hospital 3 was lower" is not of interest |
A factorial design can also be run inside blocks: every hospital gets all four cells, and people are assigned at random within each hospital. Fisher (1935) covers dividing the runs of a factorial experiment into blocks in the same chapter.
Where it is used
- Two drugs in one trial (a 2×2 factorial trial). A made-up example: 400 people are assigned at random, 100 each, to four groups: two placebos, drug A with a placebo, a placebo with drug B, and drug A with drug B. The effect of drug A is measured with the 200 who got it against the 200 who did not. The effect of drug B is measured with the same 400 people. One trial answers two questions. That only works if the effects of the two drugs simply add. With an interaction, "the effect of drug A" is only the average over people with and without drug B, so the four groups must be compared separately and more people are needed (clinical trial design).
- Multivariate tests on the web. Showing visitors one of four pages at random, two headlines × two button colors, is the same idea as a 2×2 factorial design. Compared with running two separate A/B tests, the same visitors answer both questions, and you also see interactions like "this headline works better with this color". With more elements the combinations grow as 2^k and you need many more visitors, so sometimes only part of the combinations are shown, as in a fractional factorial design.
- Finding lab conditions. When several things can be changed, such as culture temperature, nutrients and oxygen level, change them together to find which ones matter most.
- Improving a process. Experiments on a process with several settings, such as temperature, pressure and time. This is the main subject of the book by Box, Hunter and Hunter.
- How much of each ingredient. The example Fisher (1935) used to explain factorial designs: make all 16 mixtures of four ingredients, each at a larger or a smaller amount, and test them.
Frequently asked questions
Is interaction the same as confounding?
No. Confounding is when the groups you compare also differ in something else, so you get the effect wrong. Random assignment protects against it. Interaction is when the effect itself really is different at different levels of another factor. Random assignment does not remove an interaction. In epidemiology the term effect modification is used with a similar meaning.
If the interaction is not significant, can I say there is none?
No. In a 2×2 design the standard error of the difference of differences is twice that of a main effect, so catching an interaction of the same size with the same chance takes 4 times as many people. Not significant means this data does not have enough evidence to tell. Report the size of the interaction and its confidence interval too.
If there is an interaction, are main effects useless?
If the direction is the same and only the size differs, you can still report a main effect with the condition "on average, over the levels of the other factor mixed in this proportion". Report the effect at each level as well. If the lines cross and the direction flips, a single main-effect number fits no group, so report only the effects at each level.
With many factors there are too many combinations. What can I do?
With k factors at two levels each there are 2^k combinations (64 for 6 factors). If you can assume that interactions of three or more factors are small, a fractional factorial design tests a well-chosen part of the combinations. In exchange some effects get mixed up and cannot be told apart, so choose the fraction knowing which effects are mixed with which.
Why do books and software give different numbers for a 2×2 interaction?
They write the same thing on different scales. Some use the difference of differences (y₁₁ − y₀₁) − (y₁₀ − y₀₀) as it is. Books and handbooks that compute effects from a sign table (Box, Hunter and Hunter, NIST) use half of it. In a regression, coding the factors as 0 and 1 makes the interaction coefficient equal to the difference of differences, and coding them as −1 and +1 makes it one quarter of that.
Words
| Plain words used here | Textbook term |
|---|---|
| something the experimenter sets to learn its effect | factor |
| a value a factor can take | level |
| cell | treatment combination, cell |
| a design that tests every combination | (full) factorial design; with two levels each, a 2^k factorial design |
| a design that tests only part of the combinations | fractional factorial design |
| the average effect | main effect |
| the effect with the other factor held at one level | simple effect, conditional effect |
| difference of differences | interaction; in epidemiology, effect modification is used in a similar sense |
| only the size differs / the direction flips | quantitative interaction / qualitative (crossover) interaction |
| bigger together / smaller together | synergy / antagonism (pharmacology sometimes uses stricter definitions) |
| interaction plot | interaction plot, profile plot |
| sign table | table of contrasts, design matrix, model matrix |
| sum with signs attached | contrast |
| each person's data used for several effects | hidden replication |
| changing one thing at a time | one-factor-at-a-time (OFAT) |
| analysis of variance with two factors | two-way ANOVA |
| a part of the spread / that part divided by its df | sum of squares (SS) / mean square (MS); df is degrees of freedom |
| leftover (spread within cells) | error, residual |
| the same number of people in every cell | balanced design |
| mixed up so they cannot be told apart | aliasing, confounding (in fractional designs) |
| groups formed by something that moves the result | blocks |
| looking at the effect in subgroups | subgroup analysis |
| multivariate test on the web | multivariate test (MVT) |
Sources
- R. A. Fisher, The Design of Experiments, Oliver and Boyd, 1935 (Internet Archive lending copy). Chapter VI, "The Factorial Design in Experimentation": the critique of varying one factor at a time (section 37), the example of 16 mixtures of four ingredients, the interaction being symmetric in the two factors, and dividing a factorial experiment into blocks (section 38), the wider basis for conclusions (section 39), hidden replication (section 40).
- George E. P. Box, J. Stuart Hunter, William G. Hunter, Statistics for Experimenters, 2nd ed., Wiley, 2005. Chapter 5, Factorial Designs at Two Levels (5.5 main effects, 5.6 interaction effects, 5.9 the table of contrasts), chapter 6, Fractional Factorial Designs, chapter 8, Factorial Designs and Data Transformation.
- NIST/SEMATECH e-Handbook of Statistical Methods: 5.3.3.3 Full factorial designs (2^k runs, not recommended for 5 or more factors), 5.3.3.3.1 Two-level full factorial designs (the sign table, an interaction column is the product of two columns), 5.3.3.4 Fractional factorial designs, 5.5.9.4 Interaction effects matrix plot (interaction effect = mean of the + side − mean of the − side, number of interactions 2^k − 1 − k), 7.4.3.7 The two-way ANOVA (the sums of squares and how they split with equal cell sizes), 1.3.6.6.5 F Distribution (the F distribution's cumulative area through the incomplete beta function).
- NIST DLMF §8.17 Incomplete Beta Functions. The continued fraction (8.17(v)) the lab script uses for areas under the F distribution.
- Andrew Gelman, Hal Stern, The Difference Between “Significant” and “Not Significant” is not Itself Statistically Significant, The American Statistician 60(4), 2006.