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.

No dewormingDewormingRow meanNo ironIron0.36n = 50.40n = 51.18n = 52.04n = 50.381.61Column mean0.771.220.995overall meaneach cell is one combination of the two factors
Made-up teaching data, used throughout this chapter: rise in haemoglobin (g/dL) at 12 weeks. Iron has two levels (no, yes) and so does deworming, giving 2 × 2 = 4 cells. The row means give the main effect of iron: 1.61 − 0.38 = 1.23 g/dL. The column means give the main effect of deworming: 1.22 − 0.77 = 0.45 g/dL.

Two-way ANOVA analyses a measurement outcome with two factors at once. It asks three questions, each with its own F-test:

  1. Does the outcome differ between the levels of factor A, averaged over factor B? (main effect of A)
  2. Does it differ between the levels of factor B, averaged over factor A? (main effect of B)
  3. 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.

noyesIron onlylines apart and flatnoyesBoth, no interactionparallel linesnoyesInteractionlines move apartnoyesCrossover interactionlines crossdeworming (no, yes) on the horizontal axis · filled dots: iron · rings: no iron
An interaction plot puts one factor on the horizontal axis and draws a line for each level of the other factor. Parallel lines mean the effect of iron is the same with and without deworming: no interaction. Lines that move apart or cross mean the effect of one factor depends on the other. Whether the lines are far enough from parallel to be more than chance is decided by the interaction F-test, not by eye.

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.

0.36
0.40
1.18
2.04
0.33
Children per group
0123Hb rise, g/dLNo dewormingDewormingno ironiron+0.82
With ironWithout ironWhere the iron line would end if there were no interaction

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.

Two-way ANOVA table
SourceSSdfMSFpPartial η²
Iron7.56417.56469.46< 0.0010.81
Deworming1.01211.0129.300.0080.37
Iron × deworming0.84110.8417.720.0130.33
Error1.742160.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/dL95% CIp
Iron, in children not dewormed0.820.37 to 1.270.001
Iron, in children dewormed1.641.19 to 2.09< 0.001
Deworming, in children not given iron0.04−0.41 to 0.490.85
Deworming, in children given iron0.860.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.

Two separate trials: 80 childrenTrial 1ironno ironTrial 2dewormingnoneOne factorial trial: 40 childrenno dewormingdewormingno ironironiron: 20 vs 20deworming: 20 vs 20
A 2 × 2 factorial trial compares iron with no iron using all 40 children (20 vs 20), and deworming with no deworming using the same 40 children. Two separate trials of the same size per comparison need 80 children. ICH E9 notes that the efficiency and validity of this approach depend upon the absence of interaction between the two 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.

40–49 years50–59 years60–69 years70–79 yearsrandomise withineach age banddark: placeboblue: low dosered: high doseEach band has 2 patients on each dose,so age cannot favour one dose.
A randomised block design. Patients are first grouped by age band, then randomised to the three doses within each band. Differences between age bands cannot favour one dose, and the analysis can separate them from the patient-to-patient variation that the dose effect is compared with.

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.

8 mmHg

Larger → more variation that blocking can remove

0.435dose p, ignoring age band (F = 0.87, df 2, 21)
0.007dose p, with age band as a block (F = 6.60, df 2, 18)

Error mean square: 222.5 without blocks, 29.2 with blocks · dose SS 385.5 in both

-15015304560PlaceboLow doseHigh doseeach line joins one age bandWhere the variation goesIgnoring age bandAge band as a blockdoseage banderror
ANOVA tables with and without the block
AnalysisSourceSSdfFp
Ignoring age bandDose385.520.870.435
Error4672.221
Age band as a blockDose385.526.600.007
Age band4146.33
Error525.918

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)
0.36No ironno deworming0.40No irondeworming1.18Ironno deworming2.04Iron anddewormingb0 = 0.36b1 = 0.82b2 = 0.04b3 = 0.82b3: interaction
Each cell mean is a sum of coefficients. The interaction coefficient b3 appears only in the cell with both treatments. Its p-value, 0.015, is the same as the p-value of the interaction F-test, because F with 1 and 16 df equals t² (2.74² = 7.50).

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.

5 children
5 children
5 children
5 children
Sums of squares and p-values by type
Type of sums of squaresIronDewormingIron × deworming
Type I, iron entered first7.564 (p < 0.001)1.013 (p 0.008)0.840 (p 0.015)
Type I, deworming entered first7.564 (p < 0.001)1.013 (p 0.008)0.840 (p 0.015)
Type II7.564 (p < 0.001)1.013 (p 0.008)0.840 (p 0.015)
Type III7.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.

Deworming sum of squaresType I, iron entered first1.013Type I, deworming entered first1.013Type II1.013Type III1.012

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 η²
Iron7.5650.670.81
Deworming1.0130.090.36
Iron × deworming0.8410.070.32
Error1.792
Total11.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?

FeatureTwo-way ANOVATwo separate t-tests
QuestionEffect of each factor, and whether one effect depends on the otherEffect of each factor, ignoring the other
InteractionTestedNot tested, and hidden in the results
Error termWithin-cell variation only (worked example: MS 0.112)Includes the other factor’s effect, so it is larger
Worked example, dewormingInteraction F(1, 16) = 7.50, p = 0.015t(18) = 1.34, p = 0.20
ConclusionDeworming helps children who also receive ironDeworming does not help (wrong)

Main effect or interaction?

FeatureMain effectInteraction
MeaningAverage effect of one factor over the levels of the otherThe effect of one factor differs between levels of the other
On the plotDistance between the lines (or slope of both lines)Lines that are not parallel
Worked exampleIron: 1.61 − 0.38 = 1.23 g/dL1.64 − 0.82 = 0.82 g/dL
df in a 2 × 2 design1 for each factor(2 − 1) × (2 − 1) = 1
Interpret alone?Only if there is no important interactionYes. Then report simple effects

Completely randomised or randomised block design?

FeatureCompletely randomisedRandomised block
AllocationAll patients randomised to treatments togetherRandomised separately within each block (centre, age band)
AnalysisOne-way ANOVATreatment + block
Differences between blocksStay in the error termRemoved from the error term
Error df with 24 patients, 3 treatments, 4 blocks2118
SuitsSimilar patientsPatients who differ in something known to affect the outcome

Eta squared or partial eta squared?

FeatureEta squaredPartial eta squared
DenominatorTotal sum of squaresEffect SS + error SS
Values in one analysis add toAt most 1Can exceed 1
One-way ANOVASame valueSame value
Worked example, iron0.670.81
Given byjamovi (η²)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.

GroupValuesMeanSD
No iron, no deworming0.4, 0.2, 0.1, 0.4, 0.70.360.23
No iron, deworming0.7, 0.5, 0.1, 0.3, 0.40.400.22
Iron, no deworming1.6, 0.5, 1.4, 1.0, 1.41.180.44
Iron and deworming1.4, 2.0, 2.3, 2.1, 2.42.040.39
  1. 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.
  2. SS iron = 10 × [(0.38 − 0.995)² + (1.61 − 0.995)²] = 7.565, with 1 df.
  3. SS deworming = 10 × [(0.77 − 0.995)² + (1.22 − 0.995)²] = 1.013, with 1 df.
  4. SS interaction = 5 × Σ (cell mean − row mean − column mean + grand mean)² = 5 × 4 × 0.205² = 0.841, with 1 df.
  5. SS error = Σ (value − its cell mean)² = 1.792, with 4 × (5 − 1) = 16 df. MS error = 1.792 ÷ 16 = 0.112.
  6. 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
SourceSSdfMSFpPartial η²
Iron7.56517.56567.54< 0.0010.81
Deworming1.01311.0139.040.0080.36
Iron × deworming0.84110.8417.500.0150.32
Error1.792160.112
Total11.21019

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

Open-access paper · CC BY

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.

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.

What the authors wrote
“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).”
In plain words

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.

ReportedValueWhat it means
Favipiravir + placebo vs placebo−0.57 log10 (95% CI −1.21 to 0.07), p = 0.08Favipiravir 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.58Lopinavir-ritonavir alone, compared with placebo
Interaction coefficient0.59 log10 (95% CI −0.32 to 1.50), p = 0.20Departure of the combination from additive effects
Planned power for the interaction80% for 1.0 log10 copies/mL, 2-sided α 5%The trial was sized to detect a large interaction only
Participants240 recruited (61, 59, 60, 60), 224 analysedNumbers in each of the four arms
Check these when you read it
  • 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?
Open-access paper · CC BY

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.

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.

What the authors wrote
“As there was no evidence of interaction we dropped this term, allowing the overall effect of each intervention to be assessed.”
In plain words

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.

ReportedValueWhat it means
Patients in the four groups320, 318, 320, 318Aspirin + antioxidant, aspirin + placebo, placebo + antioxidant, placebo + placebo
Interaction, composite primary end pointP = 0.88No evidence that the aspirin effect differed with or without antioxidants
Aspirin vs no aspirin116/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 antioxidant117/640 (18.3%) vs 116/636 (18.2%), HR 1.03 (0.79 to 1.33)Main effect of antioxidants
Interactions in secondary end pointsdeath from stroke P = 0.004, claudication P = 0.032Two significant interactions among many tested
Check these when you read it
  • 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

  1. Analyze > General Linear Model > Univariate. Put Hb rise in Dependent Variable and iron and deworming in Fixed Factor(s).
  2. Model: Full factorial contains all factor main effects and all factor-by-factor interactions. Type III is the default sum of squares.
  3. Plots: deworming on the horizontal axis and iron as separate lines, then Add. SPSS calls these profile plots (interaction plots).
  4. EM Means: move iron*deworming across, tick Compare simple main effects, and choose a Bonferroni or Sidak confidence interval adjustment.
  5. 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 level

jamovi

  1. Use the ANOVA analysis, with Hb rise as the dependent variable and iron and deworming as fixed factors.
  2. Sum of squares: Type 3 is the default. Types 1 and 2 are also available.
  3. Effect size: choose η², partial η² or ω².
  4. 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.

  1. Name both factors, their levels, and whether they were randomised or observed.
  2. Give the number, mean and SD for every cell, not only the row and column means.
  3. State that you checked the assumptions (residuals, Levene test) and how you handled unequal cell sizes (type of sums of squares).
  4. Report F, both df and the exact p for the interaction, then for the main effects, with partial η² and what it means.
  5. If the interaction matters, report simple effects with 95% CIs and say how you adjusted for multiple tests.
  6. 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.

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

  1. 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.

  2. A wrong conclusion in the thesis

    Separate t-tests can report "no effect" for a treatment that works only together with the other treatment.

  3. 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.

  4. 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.

  5. 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

  1. 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.

  2. 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.

  3. 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.

  4. 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.

  5. 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.

  6. 2023

    Brennan Kahan and colleagues

    Published the CONSORT 2010 extension for reporting factorial randomised trials.

Guidelines

Factorial designs and interactions in guidelines

ICH E9 (1998), section 3.1.3

“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”.

ICH E9 (1998), section 5.7

“If one or more factors are used to stratify the design, it is appropriate to account for those factors in the analysis.”

CONSORT 2010 extension for factorial trials (Kahan et al., 2023), items 2a, 7a, 12a and 17a

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”.

SAMPL guidelines (Lang and Altman), reporting ANOVA or ANCOVA

“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 everyday speech

In pharmacology, one drug changing the level or action of another, such as a cytochrome P450 drug interaction.

In research

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”

In everyday speech

A solid piece of something, or a part of a city.

In research

A group of similar patients (same centre, age band or severity) within which treatments are randomised and compared.

Memory trick

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

  1. Use: a measurement outcome and two grouping factors, for example drug and sex, or two treatments in a factorial trial.
  2. 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.
  3. 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.
  4. 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.
  5. Interpretation: look at the interaction first. If present, report simple effects, not main effects.
  6. Assumptions: independent observations, roughly normal residuals, similar variances in all cells (Levene test).
  7. 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.
  8. 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

  1. Definition: patients are grouped into blocks of similar units (centre, age band, severity), and treatments are randomised within each block.
  2. Purpose: differences between blocks cannot favour one treatment, and they can be removed from the error term.
  3. 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.
  4. Contrast with completely randomised design: one-way ANOVA, block differences stay in the error term.
  5. 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.
  6. 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.