Chapter 4 · Comparing groups beyond the t-test
Do two factors act together?
Two-way ANOVA, main effects, interaction plots, factorial designs and blocking.
Read first: Choosing a test, Study designs
The problem first
You are a second-year Paediatrics resident. Your thesis randomised 20 children with mild anaemia to iron or placebo syrup, and to albendazole or placebo tablets, 5 children in each of the four combinations. At 12 weeks you run two t-tests: everyone given iron against everyone not given iron (p < 0.001), and everyone dewormed against everyone not dewormed (p = 0.20).
You write that iron works and deworming does not. Your guide writes the four group means on the board: 0.36, 0.40, 1.18 and 2.04 g/dL.
“Deworming added 0.86 g/dL in the children who also received iron. Did you test the interaction?”
Start here
What are factors, levels and cells?
A factor is a variable that divides patients into groups. Its categories are its levels. When two factors are crossed, every combination of their levels is a cell.
Two-way ANOVA analyses a measurement outcome with two factors at once. It asks three questions, each with its own F-test:
- Does the outcome differ between the levels of factor A, averaged over factor B? (main effect of A)
- Does it differ between the levels of factor B, averaged over factor A? (main effect of B)
- Does the effect of A depend on the level of B? (the interaction, A × B)
One-way ANOVA and post hoc tests are covered in the multiple comparisons chapter. The logic of F, variation between groups divided by variation within groups, is explained in the choosing a test chapter.
Two types of effect
Main effect or interaction: what is the difference?
A main effect is the average effect of one factor. An interaction means that this effect is not the same at every level of the other factor.
In the four means on the resident's board, iron raised haemoglobin by 1.18 − 0.36 = 0.82 g/dL in children who were not dewormed, and by 2.04 − 0.40 = 1.64 g/dL in children who were dewormed. The effect of iron depends on deworming. The difference between the two effects, 1.64 − 0.82 = 0.82 g/dL, is the interaction. Seen the other way, deworming added 0.04 g/dL without iron and 0.86 g/dL with iron.
When there is an interaction, a main effect is an average of two different effects. In the worked example the main effect of deworming, 0.45 g/dL, describes neither group of children: those without iron gained 0.04 g/dL from deworming and those with iron gained 0.86 g/dL. When the lines cross (a qualitative or crossover interaction), Montgomery, Peters and Little warn that the main effects “will almost certainly be misleading”.
Interactive
Set the four group means and watch the main effects and the interaction change
Try this: press "Parallel lines". The interaction sum of squares falls to 0 while both main effects remain. Then press "Lines cross": both main effects are 0, but the interaction is large.
Made-up teaching example: rise in haemoglobin (g/dL) at 12 weeks in anaemic children given iron or not and deworming or not, with the same number of children in each of the four groups.
Iron raised haemoglobin by 0.82 g/dL without deworming and by 1.64 g/dL with deworming. The difference between those two effects, +0.82 g/dL, is the interaction (F = 7.72, p = 0.013). The main effect of iron averages the two: 1.23 g/dL.
| Source | SS | df | MS | F | p | Partial η² |
|---|---|---|---|---|---|---|
| Iron | 7.564 | 1 | 7.564 | 69.46 | < 0.001 | 0.81 |
| Deworming | 1.012 | 1 | 1.012 | 9.30 | 0.008 | 0.37 |
| Iron × deworming | 0.841 | 1 | 0.841 | 7.72 | 0.013 | 0.33 |
| Error | 1.742 | 16 | 0.109 |
After the F-tests
What do you do when the interaction is significant?
Report the effect of each factor separately at each level of the other factor. These are called simple effects.
| Simple effect (worked example) | Difference, g/dL | 95% CI | p |
|---|---|---|---|
| Iron, in children not dewormed | 0.82 | 0.37 to 1.27 | 0.001 |
| Iron, in children dewormed | 1.64 | 1.19 to 2.09 | < 0.001 |
| Deworming, in children not given iron | 0.04 | −0.41 to 0.49 | 0.85 |
| Deworming, in children given iron | 0.86 | 0.41 to 1.31 | < 0.001 |
Each test uses the error mean square from the two-way ANOVA (0.112, 16 df), so the standard error of each difference is √(0.112 × 2 ÷ 5) = 0.212. Four simple effects are four tests, so adjust the p-values for the number of tests. With the Holm method the conclusions here do not change (adjusted p = 0.003, < 0.001, 0.85 and 0.003).
How to adjust p-values for several tests is explained in the multiple comparisons chapter.
Design
Why test two treatments in one factorial trial?
In a factorial design every level of one factor is combined with every level of the other, so each patient contributes to the comparison of both treatments.
The interaction needs more patients
A main-effect comparison uses the difference between two averages of 2n patients each, so its standard error is σ ÷ √n (n = patients per cell). The interaction contrast, (iron and deworming − deworming alone) − (iron alone − neither), combines four cell means and has a standard error of 2σ ÷ √n, twice as large. To detect an interaction contrast as large as a main-effect difference with the same power, a trial needs about four times as many patients. In the worked example the two standard errors are 0.150 and 0.299 g/dL.
SE(main effect) = σ ÷ √n
SE(interaction contrast) = 2σ ÷ √n
ICH E9 states that the test of interaction “may lack power to detect an interaction if the sample size was calculated based on the test for main effects”. A non-significant interaction in a trial sized for main effects does not show that the treatments are additive.
Design
What does blocking do?
A block is a group of patients who are similar in something that affects the outcome, such as age band, centre or severity. Randomising within each block and analysing the block as a factor removes the differences between blocks from the error term.
In a completely randomised design patients are allocated to doses without regard to age. The one-way ANOVA error term then contains both the differences between patients of the same age and the differences between age bands. In a randomised block design the block is entered into a two-way analysis (treatment + block). The treatment sum of squares is the same, but the error sum of squares becomes smaller, so F for treatment becomes larger. The cost is 3 degrees of freedom for 4 blocks.
ICH E9 (section 5.7) states that if one or more factors are used to stratify the design, it is appropriate to account for those factors in the analysis. In a multicentre trial with randomisation stratified by centre, centre is a block.
Interactive
Change how much the age bands differ and watch blocking change the p-value for dose
Try this: move the difference between age bands from 8 down to 0 mmHg, then up to 12. The p-value for dose from the one-way analysis changes a great deal. The p-value from the analysis that includes age band does not change at all, because a difference that is the same for every patient in a band is removed by the block term.
Simulated teaching data: fall in systolic blood pressure (mmHg) with placebo, a low dose or a high dose. Patients were randomised within four age bands, 2 to each dose in each band. True dose effects 0, 3 and 6 mmHg; SD between patients 5 mmHg.
Larger → more variation that blocking can remove
Error mean square: 222.5 without blocks, 29.2 with blocks · dose SS 385.5 in both
| Analysis | Source | SS | df | F | p |
|---|---|---|---|---|---|
| Ignoring age band | Dose | 385.5 | 2 | 0.87 | 0.435 |
| Error | 4672.2 | 21 | |||
| Age band as a block | Dose | 385.5 | 2 | 6.60 | 0.007 |
| Age band | 4146.3 | 3 | |||
| Error | 525.9 | 18 |
The model
How is two-way ANOVA the same as a regression model?
Code each factor as 0 or 1 and add their product. A linear regression with these three terms reproduces the four cell means exactly.
Hb rise = b0 + b1 × iron + b2 × deworming + b3 × (iron × deworming)
- b0 = 0.36
- mean in children given neither treatment
- b1 = 0.82
- effect of iron in children not dewormed
- b2 = 0.04
- effect of deworming in children not given iron
- b3 = 0.82
- interaction: the extra effect when both are given (95% CI 0.19 to 1.45, p = 0.015)
With 0/1 (dummy) coding and the product term in the model, b1 and b2 are simple effects at the reference level of the other factor, not main effects. To get main-effect tests from a regression, software codes factors as −1 and +1 (sum-to-zero coding). This is why the documentation of the R package car warns that type III tests only make sense with contrasts such as contr.sum, and not with the default contr.treatment. Reading regression output is covered in the correlation and regression chapter.
A caveat
What changes when the groups are not the same size?
With equal numbers in every cell, the effects of the two factors can be separated exactly. With unequal numbers they overlap, and the sum of squares for a factor depends on what else is already in the model.
- Type I (sequential): each term is tested after the terms entered before it. The order matters: iron then deworming gives a different answer from deworming then iron.
- Type II: each main effect is tested after the other main effect, ignoring the interaction.
- Type III: each term is tested after all the others, including the interaction.
All three types agree when the design is balanced, and the interaction sum of squares is the same in all three because it is always tested last. SPSS GLM Univariate uses Type III by default, as does jamovi. R's aov() documentation states that it is designed for balanced designs and that results can be hard to interpret without balance. Plan equal groups where you can, and state in the methods which type of sums of squares you used.
Interactive
Change the number of children in each group and watch the three types of sums of squares separate
Try this: start with 5 children in every group: all four rows of the table agree. Then press "Only 2 with iron and deworming" and watch the iron and deworming columns change from row to row while the interaction column stays the same.
Made-up teaching example. The group means stay at the worked-example values (0.36, 0.40, 1.18 and 2.04 g/dL) and the SD within each group stays at 0.33. Only the numbers of children change.
| Type of sums of squares | Iron | Deworming | Iron × deworming |
|---|---|---|---|
| Type I, iron entered first | 7.564 (p < 0.001) | 1.013 (p 0.008) | 0.840 (p 0.015) |
| Type I, deworming entered first | 7.564 (p < 0.001) | 1.013 (p 0.008) | 0.840 (p 0.015) |
| Type II | 7.564 (p < 0.001) | 1.013 (p 0.008) | 0.840 (p 0.015) |
| Type III | 7.564 (p < 0.001) | 1.012 (p 0.008) | 0.840 (p 0.015) |
With these numbers the design is balanced, so every type gives the same sums of squares. 20 children, error df 16.
Effect size
How large is each effect? Partial eta squared
A p-value tells you whether an effect could be chance. Eta squared and partial eta squared describe how much of the variation in the outcome an effect accounts for.
η² = SS effect ÷ SS total
partial η² = SS effect ÷ (SS effect + SS error)
| Effect (worked example) | SS | η² | Partial η² |
|---|---|---|---|
| Iron | 7.565 | 0.67 | 0.81 |
| Deworming | 1.013 | 0.09 | 0.36 |
| Iron × deworming | 0.841 | 0.07 | 0.32 |
| Error | 1.792 | ||
| Total | 11.210 |
Eta squared values from one analysis add up to no more than 1, because each is a share of the same total. Partial eta squared leaves the other effects out of the denominator, so the values can add up to more than 1: here 0.81 + 0.36 + 0.32 = 1.49. SPSS labels its “Estimates of effect size” output as partial eta squared. Lakens (2013) notes that researchers predominantly report partial eta squared because SPSS provides it. State which one you report.
Decide
Which analysis fits a study with two factors?
Answer the questions in order.
How many grouping factors does your study have?
Which analysis: all possible answers
- One-way ANOVA: One factor with three or more groups. Follow a significant result with a post hoc test.
- Repeated measures (mixed) ANOVA or a linear mixed model: Measurements from the same patient are not independent, so an ordinary two-way ANOVA is not valid.
- Randomised block analysis: Analyse treatment and block together. Differences between blocks then leave the error term.
- A regression model suited to the outcome: Logistic regression for a yes/no outcome or Poisson regression for counts, with both factors and their product term. A skewed measurement may be analysed after a log transformation.
- Two-way ANOVA: Look at the interaction first. With equal numbers in every cell, every type of sums of squares gives the same answer.
- Two-way ANOVA with a stated type of sums of squares: With unequal cells, Type I, II and III sums of squares test different hypotheses and can give different p-values. State which type you used.
Comparison
Pairs of ideas that residents confuse
Two-way ANOVA or two separate t-tests?
| Feature | Two-way ANOVA | Two separate t-tests |
|---|---|---|
| Question | Effect of each factor, and whether one effect depends on the other | Effect of each factor, ignoring the other |
| Interaction | Tested | Not tested, and hidden in the results |
| Error term | Within-cell variation only (worked example: MS 0.112) | Includes the other factor’s effect, so it is larger |
| Worked example, deworming | Interaction F(1, 16) = 7.50, p = 0.015 | t(18) = 1.34, p = 0.20 |
| Conclusion | Deworming helps children who also receive iron | Deworming does not help (wrong) |
Main effect or interaction?
| Feature | Main effect | Interaction |
|---|---|---|
| Meaning | Average effect of one factor over the levels of the other | The effect of one factor differs between levels of the other |
| On the plot | Distance between the lines (or slope of both lines) | Lines that are not parallel |
| Worked example | Iron: 1.61 − 0.38 = 1.23 g/dL | 1.64 − 0.82 = 0.82 g/dL |
| df in a 2 × 2 design | 1 for each factor | (2 − 1) × (2 − 1) = 1 |
| Interpret alone? | Only if there is no important interaction | Yes. Then report simple effects |
Completely randomised or randomised block design?
| Feature | Completely randomised | Randomised block |
|---|---|---|
| Allocation | All patients randomised to treatments together | Randomised separately within each block (centre, age band) |
| Analysis | One-way ANOVA | Treatment + block |
| Differences between blocks | Stay in the error term | Removed from the error term |
| Error df with 24 patients, 3 treatments, 4 blocks | 21 | 18 |
| Suits | Similar patients | Patients who differ in something known to affect the outcome |
Eta squared or partial eta squared?
| Feature | Eta squared | Partial eta squared |
|---|---|---|
| Denominator | Total sum of squares | Effect SS + error SS |
| Values in one analysis add to | At most 1 | Can exceed 1 |
| One-way ANOVA | Same value | Same value |
| Worked example, iron | 0.67 | 0.81 |
| Given by | jamovi (η²) | SPSS Estimates of effect size, jamovi (partial η²) |
The formula
Worked example: two-way ANOVA by hand
Made-up teaching data. Rise in haemoglobin (g/dL) at 12 weeks, 5 children in each of four groups.
| Group | Values | Mean | SD |
|---|---|---|---|
| No iron, no deworming | 0.4, 0.2, 0.1, 0.4, 0.7 | 0.36 | 0.23 |
| No iron, deworming | 0.7, 0.5, 0.1, 0.3, 0.4 | 0.40 | 0.22 |
| Iron, no deworming | 1.6, 0.5, 1.4, 1.0, 1.4 | 1.18 | 0.44 |
| Iron and deworming | 1.4, 2.0, 2.3, 2.1, 2.4 | 2.04 | 0.39 |
- Grand mean = 19.9 ÷ 20 = 0.995. Row means: no iron 0.38, iron 1.61. Column means: no deworming 0.77, deworming 1.22.
- SS iron = 10 × [(0.38 − 0.995)² + (1.61 − 0.995)²] = 7.565, with 1 df.
- SS deworming = 10 × [(0.77 − 0.995)² + (1.22 − 0.995)²] = 1.013, with 1 df.
- SS interaction = 5 × Σ (cell mean − row mean − column mean + grand mean)² = 5 × 4 × 0.205² = 0.841, with 1 df.
- SS error = Σ (value − its cell mean)² = 1.792, with 4 × (5 − 1) = 16 df. MS error = 1.792 ÷ 16 = 0.112.
- F = MS effect ÷ MS error. The critical F for (1, 16) df at 5% is 4.49.
- SS
- sum of squares
- MS
- mean square = SS ÷ df
- n
- children per cell (5); each row or column mean is based on 2n = 10 children
| Source | SS | df | MS | F | p | Partial η² |
|---|---|---|---|---|---|---|
| Iron | 7.565 | 1 | 7.565 | 67.54 | < 0.001 | 0.81 |
| Deworming | 1.013 | 1 | 1.013 | 9.04 | 0.008 | 0.36 |
| Iron × deworming | 0.841 | 1 | 0.841 | 7.50 | 0.015 | 0.32 |
| Error | 1.792 | 16 | 0.112 | |||
| Total | 11.210 | 19 |
F(interaction) = 0.841 ÷ 0.112 = 7.50, df 1 and 16 → p = 0.015
Read the interaction first. It is significant, so the main effect of deworming (p = 0.008) is not a useful summary on its own. Report the simple effects instead: iron raised haemoglobin by 0.82 g/dL without deworming and 1.64 g/dL with it. Deworming added 0.04 g/dL without iron (p = 0.85) and 0.86 g/dL with iron (p < 0.001).
The resident's separate t-tests on the same 20 values gave t(18) = 6.11, p < 0.001 for iron and t(18) = 1.34, p = 0.20 for deworming. The deworming t-test mixed children with and without iron, so the effect of deworming in children given iron was lost.
All results were computed in Python (statsmodels 0.14.5). The design is balanced, so Type I, II and III sums of squares are identical.
In a real paper
How a 2 × 2 factorial trial reports the interaction
Lowe DM, Brown LK, Chowdhury K, Davey S, Yee P, Ikeji F, et al. Favipiravir, lopinavir-ritonavir, or combination therapy (FLARE): a randomised, double-blind, 2 × 2 factorial placebo-controlled trial of early antiviral therapy in COVID-19. PLoS Med. 2022;19(10):e1004120.
doi:10.1371/journal.pmed.1004120 · PMID 36260627 · Free full text (PMC9629589)
The study: A phase 2 trial in 240 outpatients with early COVID-19 in two UK centres. Patients were randomised to favipiravir plus lopinavir-ritonavir, favipiravir plus placebo, lopinavir-ritonavir plus placebo, or both placebos. Viral load at day 5 was analysed with a term for each drug, an interaction term between the two drugs, and baseline viral load.
“There was no significant interaction between favipiravir and lopinavir-ritonavir (interaction coefficient term: 0.59 log10, 95% CI −0.32 to 1.50, p = 0.20).”
The interaction coefficient is how much the effect of the two drugs together differs from the sum of their separate effects, in log10 copies/mL. A positive value means the combination lowered the viral load less than the two separate effects added together would predict. The authors describe the coefficient as “numerically in the direction of antagonism”. The 95% CI runs from −0.32 to 1.50: it includes 0 (no interaction) but also values larger than either drug's own effect, so the trial cannot show that the drugs simply add together.
| Reported | Value | What it means |
|---|---|---|
| Favipiravir + placebo vs placebo | −0.57 log10 (95% CI −1.21 to 0.07), p = 0.08 | Favipiravir alone, compared with placebo. With an interaction term in the model, this is not averaged over the other drug. |
| Lopinavir-ritonavir + placebo vs placebo | −0.18 log10 (95% CI −0.82 to 0.46), p = 0.58 | Lopinavir-ritonavir alone, compared with placebo |
| Interaction coefficient | 0.59 log10 (95% CI −0.32 to 1.50), p = 0.20 | Departure of the combination from additive effects |
| Planned power for the interaction | 80% for 1.0 log10 copies/mL, 2-sided α 5% | The trial was sized to detect a large interaction only |
| Participants | 240 recruited (61, 59, 60, 60), 224 analysed | Numbers in each of the four arms |
- Was the interaction test planned, and was the trial powered for it? Here it was, for an interaction of 1.0 log10.
- With a product term in the model, do the reported drug effects compare each drug alone with placebo? Here they do.
- Does a non-significant interaction come with a confidence interval? A wide interval means the question is unanswered.
- Are the results for all four arms reported, as the CONSORT extension for factorial trials asks?
Belch J, MacCuish A, Campbell I, Cobbe S, Taylor R, Prescott R, et al. The prevention of progression of arterial disease and diabetes (POPADAD) trial: factorial randomised placebo controlled trial of aspirin and antioxidants in patients with diabetes and asymptomatic peripheral arterial disease. BMJ. 2008;337:a1840.
doi:10.1136/bmj.a1840 · PMID 18927173 · Free full text (PMC2658865)
The study: Patients with diabetes and asymptomatic peripheral arterial disease were randomised in a 2 × 2 factorial design to aspirin or placebo tablets and to antioxidant or placebo capsules. The two questions shared one set of patients, which is efficient only if aspirin and antioxidants do not interact.
“As there was no evidence of interaction we dropped this term, allowing the overall effect of each intervention to be assessed.”
The authors first fitted a model with aspirin, antioxidants and an aspirin × antioxidant interaction. The interaction was not significant, so they removed it and compared all patients given aspirin with all given placebo tablets, and all given antioxidants with all given placebo capsules. That is the efficient factorial analysis. It depends on there being no interaction, and the authors note that the power to detect an interaction was low.
| Reported | Value | What it means |
|---|---|---|
| Patients in the four groups | 320, 318, 320, 318 | Aspirin + antioxidant, aspirin + placebo, placebo + antioxidant, placebo + placebo |
| Interaction, composite primary end point | P = 0.88 | No evidence that the aspirin effect differed with or without antioxidants |
| Aspirin vs no aspirin | 116/638 vs 117/638 (18.2% v 18.3%), HR 0.98 (0.76 to 1.26) | Main effect of aspirin, using all 1276 patients |
| Antioxidant vs no antioxidant | 117/640 (18.3%) vs 116/636 (18.2%), HR 1.03 (0.79 to 1.33) | Main effect of antioxidants |
| Interactions in secondary end points | death from stroke P = 0.004, claudication P = 0.032 | Two significant interactions among many tested |
- The authors note that "the power to detect an interaction was low". A non-significant interaction test was the basis for dropping the term.
- The CONSORT factorial extension states that using a test of interaction to guide the choice of analysis can introduce bias.
- Several secondary end points were tested for interaction. Two P-values below 0.05 among many tests can arise by chance.
- Table 2 gives results for each of the four groups, so readers can look at the cells themselves.
Software
How to run a two-way ANOVA
The steps below were checked against the IBM SPSS Statistics documentation, the CRAN reference manuals and the jamovi documentation in September 2026.
SPSS
- Analyze > General Linear Model > Univariate. Put Hb rise in Dependent Variable and iron and deworming in Fixed Factor(s).
- Model: Full factorial contains all factor main effects and all factor-by-factor interactions. Type III is the default sum of squares.
- Plots: deworming on the horizontal axis and iron as separate lines, then Add. SPSS calls these profile plots (interaction plots).
- EM Means: move iron*deworming across, tick Compare simple main effects, and choose a Bonferroni or Sidak confidence interval adjustment.
- Options: tick Estimates of effect size (partial eta-squared) and Homogeneity tests (Levene).
R
d$iron <- factor(d$iron)
d$deworm <- factor(d$deworm)
fit <- aov(hb ~ iron * deworm, data = d) # aov() is designed for balanced designs
summary(fit)
interaction.plot(d$deworm, d$iron, d$hb)
# Type III tests need sum-to-zero contrasts (car documentation)
library(car)
fit3 <- lm(hb ~ iron * deworm, data = d,
contrasts = list(iron = contr.sum, deworm = contr.sum))
Anova(fit3, type = "III") # Anova() uses type "II" unless told otherwise
library(effectsize)
eta_squared(fit, partial = TRUE) # uses anova(fit): fine for a balanced design
library(emmeans)
emmeans(fit, pairwise ~ iron | deworm) # simple effects of iron within each deworming leveljamovi
- Use the ANOVA analysis, with Hb rise as the dependent variable and iron and deworming as fixed factors.
- Sum of squares: Type 3 is the default. Types 1 and 2 are also available.
- Effect size: choose η², partial η² or ω².
- Estimated marginal means: add the iron × deworming term. Plots of the estimated marginal means are drawn by default.
# the same analysis from R with the jmv package that runs jamovi analyses
jmv::ANOVA(formula = hb ~ iron + deworm + iron:deworm, data = d,
ss = "3", effectSize = "partEta", emMeans = ~ iron:deworm)Reporting
How to report a two-way ANOVA
Report the design, the cell means and SDs, the interaction first, then the main effects or the simple effects, each with an effect size and a confidence interval.
- Name both factors, their levels, and whether they were randomised or observed.
- Give the number, mean and SD for every cell, not only the row and column means.
- State that you checked the assumptions (residuals, Levene test) and how you handled unequal cell sizes (type of sums of squares).
- Report F, both df and the exact p for the interaction, then for the main effects, with partial η² and what it means.
- If the interaction matters, report simple effects with 95% CIs and say how you adjusted for multiple tests.
- Name the software and version.
A sentence for your thesis, using this chapter's teaching numbers:
Haemoglobin rise at 12 weeks was analysed by two-way ANOVA with iron, deworming and their interaction as fixed factors. The iron × deworming interaction was significant (F(1, 16) = 7.50, p = 0.015, partial η² = 0.32). Iron raised haemoglobin by 0.82 g/dL (95% CI 0.37 to 1.27) in children who were not dewormed and by 1.64 g/dL (95% CI 1.19 to 2.09) in children who were dewormed. Deworming without iron had little effect (0.04 g/dL, 95% CI −0.41 to 0.49).
The SAMPL guidelines (Lang and Altman) ask authors reporting ANOVA to “specify whether the explanatory variables were tested for interaction, and if so how these interactions were treated”. For factorial trials, the CONSORT 2010 extension (Kahan et al., 2023) asks for the estimated interaction effect and its precision for each primary outcome.
By specialty
Two-factor questions by specialty
Nausea score (0–10) after ondansetron or placebo, in patients having laparoscopic or open surgery. Type of surgery is observed, not randomised.
The interaction asks whether ondansetron reduces nausea by the same amount after both types of surgery.
HbA1c at 6 months in a 2 × 2 factorial trial: metformin dose 500 or 1000 mg, and dietary counselling or usual advice.
Test the interaction first. If the dose effect depends on counselling, report the dose effect separately with and without counselling.
Pain score on day 1 with two local anaesthetic infiltrations and two skin closure techniques, both randomised.
One factorial trial answers two questions with the same patients, provided the two treatments do not interact.
Duration of diarrhoea (days) with zinc or placebo and probiotic or placebo. A few children have long illnesses.
Days of illness are skewed. Check residuals, and consider a log transformation before a two-way ANOVA.
A multicentre trial of two labour analgesia methods, randomised separately within each of five hospitals.
Hospital is a block. ICH E9 advises that factors used to stratify the design are accounted for in the analysis.
HAM-D score after an antidepressant or placebo, combined with CBT or a waiting list.
If the question is whether the combination adds more than either alone, the trial must be large enough to detect an interaction.
Serum enzyme levels in male and female rats given saline or one of three doses, six rats per cell.
Plot dose against enzyme level with a line for each sex. Lines that are not parallel suggest that the dose response differs by sex.
Diarrhoea episodes per child in villages given handwashing promotion, water chlorination, both or neither.
Episodes are counts: use a Poisson-type model with both interventions and their product term, allowing for clustering by village.
Common myths
Common mistaken beliefs
Myth: A non-significant interaction proves that the two factors do not interact.
The interaction test has less power than the main-effect tests. ICH E9 warns that it may lack power if the sample size was based on main effects. Look at the confidence interval.
Myth: Two separate t-tests give the same answer as a two-way ANOVA.
In the worked example the t-test for deworming gave p = 0.20, while the two-way analysis showed that deworming added 0.86 g/dL in children given iron.
Myth: Test the interaction first, then decide which analysis to report.
The CONSORT extension for factorial trials states that using a test of interaction to guide the choice of analysis can introduce bias and is not recommended. Decide in the protocol.
Myth: Parallel-looking lines on the plot prove there is no interaction.
Plotted means vary by chance. Whether lines differ from parallel is judged by the interaction test and its confidence interval. An interaction can also appear on one scale and not another, for example on the risk difference scale but not the risk ratio scale.
Myth: Partial eta squared values add up to 100%.
Only eta squared values share one denominator. In the worked example the partial eta squared values add up to 1.49.
Myth: Main effects can always be interpreted.
When lines cross, main effects average opposite effects and can be misleading. Report simple effects.
Why this matters to you
Five consequences of ignoring the interaction
Protocol sent back
A factorial design with a sample size based only on main effects cannot answer a question about the combination. The committee may ask whether the interaction is the aim.
A wrong conclusion in the thesis
Separate t-tests can report "no effect" for a treatment that works only together with the other treatment.
Questions you cannot answer at the viva
"What is an interaction?", "Why did you not report simple effects?" and "Which type of sums of squares did you use?" need direct answers.
Misreading factorial trials
Main effects from a factorial trial are valid summaries only if the two treatments do not interact. Check whether the trial could detect an interaction.
Harm to patients
A combination may be adopted, or rejected, on the basis of main effects when the benefit depends on giving both treatments together.
History
History of factorial experiments and two-way analysis
- 1923
Ronald Fisher and W. A. Mackenzie
Published "The manurial response of different potato varieties", the first paper on analysis of variance. Its title names two factors studied together: variety and manure.
- 1934
Frank Yates
Published "The analysis of multiple classifications with unequal numbers in the different classes". Herr (1986) traces the history of analysing unbalanced factorial designs back to Yates's papers of 1933 and 1934.
- 1988
ISIS-2 Collaborative Group
Reported a randomised trial of intravenous streptokinase, oral aspirin, both, or neither among 17,187 patients with suspected myocardial infarction: a 2 × 2 factorial trial.
- 1998
ICH E9
Described factorial designs in its guideline on statistical principles for clinical trials, and noted that the test of interaction may lack power.
- 2003
Finlay McAlister, Sharon Straus, David Sackett and Douglas Altman
Reviewed 44 factorial trials with binary outcomes: 26 (59%) reported testing for interactions, and only 2 of 31 comparisons showed a statistically significant interaction.
- 2023
Brennan Kahan and colleagues
Published the CONSORT 2010 extension for reporting factorial randomised trials.
Guidelines
Factorial designs and interactions in guidelines
“The statistical test of interaction may lack power to detect an interaction if the sample size was calculated based on the test for main effects.” The efficiency and validity of using a 2×2 design to evaluate two treatments “depends upon the absence of interaction between treatments A and B”.
“If one or more factors are used to stratify the design, it is appropriate to account for those factors in the analysis.”
Report the “rationale for using a factorial design, including whether an interaction is hypothesized”, how sample size was determined “including whether an interaction was assumed in the calculation”, the “method(s) used to evaluate statistical interaction(s)”, and “for each primary outcome, the estimated interaction effect and its precision”.
“Specify whether the explanatory variables were tested for interaction, and if so how these interactions were treated.”
Reading a paper
Five checks on any two-way ANOVA or factorial trial
- Are the mean, SD and number given for every cell, not only for each factor?
- Was the interaction tested, with its estimate and confidence interval reported?
- If there was an interaction, did the authors report simple effects instead of relying on main effects?
- Was the trial large enough to detect an interaction, or was it sized only for main effects?
- If the cells were unequal, did the authors state which type of sums of squares they used?
Why is it called that?
Word surgery
“Interaction”
In pharmacology, one drug changing the level or action of another, such as a cytochrome P450 drug interaction.
The effect of one factor on the outcome differs across the levels of another factor. It is a property of the data model, and it can exist without any pharmacological interaction.
“Block”
A solid piece of something, or a part of a city.
A group of similar patients (same centre, age band or severity) within which treatments are randomised and compared.
Parallel lines: no interaction. Lines that move apart or cross: look at the interaction test first, then report the effect of each factor at each level of the other.
Factor
Latin factor: "doer, maker, performer"
A variable whose levels divide patients into groups. The sense "circumstance producing a result" dates from 1816.
Interaction
inter- "between" + action: "mutual or reciprocal action, influence of things on each other" (1807)
In ANOVA, the effect of one factor depends on the level of the other.
Main
Old English mægen "power, strength"; the sense "chief, principal" dates from about 1400
A main effect is the principal, averaged effect of one factor.
Level
Latin libella: "a balance, level", from libra "balance, scale"
One of the categories of a factor, such as iron or no iron.
Block
Old French bloc "log, block" of wood; generalised to any solid piece by the late 15th century
In experiments, a group of similar units within which treatments are randomised.
Exam answers
Short-note outlines
Two-way ANOVA: principle, main effects and interaction
- Use: a measurement outcome and two grouping factors, for example drug and sex, or two treatments in a factorial trial.
- Principle: total variation is divided into the part due to factor A, factor B, the A × B interaction and error. Each F = MS effect ÷ MS error.
- Degrees of freedom: a − 1 for A, b − 1 for B, (a − 1)(b − 1) for the interaction, ab(n − 1) for error with n per cell.
- Main effect: average effect of one factor over the levels of the other. Interaction: the effect of one factor differs between levels of the other. Seen as non-parallel lines on an interaction plot.
- Interpretation: look at the interaction first. If present, report simple effects, not main effects.
- Assumptions: independent observations, roughly normal residuals, similar variances in all cells (Levene test).
- Example: iron and deworming, 5 children per cell. Interaction F(1, 16) = 7.50, p = 0.015. Iron effect 0.82 g/dL without deworming and 1.64 g/dL with it.
- Effect size: partial η² = SS effect ÷ (SS effect + SS error).
Factorial designs in clinical trials: advantages and limitations
- Definition: every level of one factor is combined with every level of another. The simplest is the 2 × 2 design: A alone, B alone, both, neither (ICH E9).
- Advantage 1, efficiency: two treatments are evaluated with the patients of one trial, because every patient contributes to both comparisons, provided there is no interaction.
- Advantage 2: the only design that allows the interaction between two treatments to be estimated.
- Limitation 1: an interaction contrast has twice the standard error of a main effect, so detecting an interaction of the same size needs about four times the sample size.
- Limitation 2: if there is a qualitative interaction, main effects are misleading and the efficiency is lost.
- Limitation 3: some combinations may not be feasible or ethical.
- Example: ISIS-2 (1988), streptokinase, aspirin, both or neither in 17,187 patients.
- Reporting: CONSORT extension for factorial trials (2023): rationale, whether an interaction was assumed in the sample size, and the estimated interaction with its precision.
Randomised block design
- Definition: patients are grouped into blocks of similar units (centre, age band, severity), and treatments are randomised within each block.
- Purpose: differences between blocks cannot favour one treatment, and they can be removed from the error term.
- Analysis: two-way ANOVA with treatment and block. The treatment SS is unchanged, the error SS becomes smaller, and F for treatment becomes larger. Blocks use b − 1 degrees of freedom.
- Contrast with completely randomised design: one-way ANOVA, block differences stay in the error term.
- In clinical trials: stratified randomisation by centre. ICH E9 section 5.7: factors used to stratify the design should be accounted for in the analysis.
- Limitation: blocking helps only if the blocking variable is related to the outcome. Otherwise it uses degrees of freedom for nothing.
The one thing to remember
Look at the interaction before the main effects. If the effect of one factor depends on the other, report it separately at each level.
All worked examples and interactive elements use made-up or simulated numbers for teaching. Every statistic was computed in Python (SciPy 1.15.3, statsmodels 0.14.5) and checked against the interactive elements.
Sources: Lowe DM et al. PLoS Med 2022;19(10):e1004120 (doi:10.1371/journal.pmed.1004120, PMID 36260627). Belch J et al. BMJ 2008;337:a1840 (doi:10.1136/bmj.a1840, PMID 18927173). Montgomery AA, Peters TJ, Little P. BMC Med Res Methodol 2003;3:26 (doi:10.1186/1471-2288-3-26, PMID 14633287). McAlister FA, Straus SE, Sackett DL, Altman DG. JAMA 2003;289(19):2545–53 (doi:10.1001/jama.289.19.2545, PMID 12759326). Kahan BC et al. Reporting of factorial randomized trials: extension of the CONSORT 2010 statement. JAMA 2023;330(21):2106–14 (doi:10.1001/jama.2023.19793, PMID 38051324). Lakens D. Front Psychol 2013;4:863 (doi:10.3389/fpsyg.2013.00863, PMID 24324449). ISIS-2 Collaborative Group. Lancet 1988;2(8607):349–60 (PMID 2899772). Fisher RA, Mackenzie WA. J Agric Sci 1923;13(3):311–20 (doi:10.1017/S0021859600003592). Cochran WG. Fisher and the analysis of variance. 1980 (doi:10.1007/978-1-4612-6079-0_4). Yates F. J Am Stat Assoc 1934;29(185):51–66 (doi:10.1080/01621459.1934.10502686). Herr DG. On the history of ANOVA in unbalanced, factorial designs: the first 30 years. Am Stat 1986 (doi:10.1080/00031305.1986.10475409). ICH E9 Statistical Principles for Clinical Trials, 5 February 1998. Lang T, Altman D. SAMPL Guidelines (EQUATOR Network); Int J Nurs Stud 2015;52(1):5–9 (doi:10.1016/j.ijnurstu.2014.09.006). IBM SPSS Statistics documentation (GLM Univariate, GLM Model, GLM Options, GLM Profile Plots, GLM Estimated Marginal Means). R documentation for aov, summary.aov and interaction.plot (stats 4.5.0). CRAN reference manuals: car 3.1-5, effectsize 1.0.3, emmeans 2.0.4, jmv 2.8.0. Etymologies: Online Etymology Dictionary, accessed 15 September 2026.
Further reading: Jawlik A. Statistics from A to Z: Confusing Concepts Clarified. Hoboken: Wiley; 2016. Indrayan A. Medical Biostatistics. Boca Raton: CRC Press.