- Introduced by
- Ronald A. Fisher
- Year
- 1925
- Type
- Parametric factorial mean comparison
What does it do?
Two-Way ANOVA is a parametric hypothesis test that examines, in one analysis, the main effects of two independent categorical factors and their interaction on a single continuous dependent variable.
It was developed within the analysis of variance framework that Ronald A. Fisher established in 1925. It is the usual choice when an experiment or survey has exactly two between-subjects factors.
The intuition behind the method
Suppose you want to know whether a new drug works and whether its effect depends on the patient's sex. Two separate one-way ANOVAs would not answer the most interesting question: does the drug work differently for men than for women? Two-Way ANOVA addresses three questions at once. Does Factor A matter on its own? Does Factor B matter on its own? Does the combination of A and B produce an outcome that neither factor predicts alone? The method splits the total variability into four parts: variance due to A, variance due to B, variance due to the A-by-B interaction, and residual error. It then tests whether each part is too large to be explained by chance alone.
History
Ronald A. Fisher developed the analysis of variance, as set out in his 1925 work on statistical methods for research workers. The factorial extension, which tests two or more factors and their interactions together, belongs to the same framework. Douglas Montgomery's Design and Analysis of Experiments, in its ninth edition (2017), is a standard reference for factorial ANOVA in engineering and applied sciences.
When to use it
Use Two-Way ANOVA when the outcome is a single continuous variable, there are exactly two categorical between-subjects factors with two or more levels each, and the observations are independent. The model assumes that residuals within each cell are approximately normal and that variances are similar across cells. The sample needed depends on the number of cells, the expected effect size and the desired power, so a power analysis is the best guide; each cell should hold enough cases to estimate its mean and variance reasonably. When cell sizes are unequal, sequential (Type I) sums of squares depend on the order in which the factors are entered. Choose Type II or Type III deliberately and report which was used; Type III is often used when the interaction is retained in the model. If normality or equal variance is doubtful, consider an Aligned Rank Transform (ART) ANOVA or a permutation test, both of which keep the two-factor structure. Do not use it for repeated measurements on the same subjects, which call for repeated-measures ANOVA. Do not use it when a continuous covariate must be adjusted for, which calls for ANCOVA, or when there are several correlated outcomes, which calls for MANOVA.
Limitations and considerations
- Needs enough observations in every cell for stable estimates; the required total depends on the number of cells, the expected effect size and the desired power.
- F tests depend on normal residuals and equal variances across cells, and these assumptions matter most in small or unbalanced designs.
- A significant interaction makes the main effects conditional, so they are harder to interpret and usually need simple-effects tests or an interaction plot.
- Designed for between-subjects factors only; repeated measurements on the same units need a model that accounts for the within-subject correlation.
Source conditions do not replace independent scientific review or validation by an analysis engine.
Strengths
- Tests both main effects and their interaction in one model, which is more efficient than running separate one-way tests on each factor.
- Detects interaction effects that separate one-way analyses cannot detect, because they never model the cross-classification of the two factors.
- The F-test framework and its assumptions are thoroughly documented in standard references such as Montgomery (2017).
- Partial eta-squared gives each effect a standardised size relative to its own error, which makes effects easier to compare across studies with similar designs.
Applications
- Clinical trials testing a treatment across two patient subgroups (for example, drug type by sex) to check whether efficacy differs between them.
- Educational research examining whether a teaching method performs differently across age groups or school types.
- Agricultural and biological experiments studying the joint effect of two treatments, such as fertiliser type and irrigation level, on crop yield.
- Industrial process studies assessing how two process factors, such as temperature and pressure, affect a product characteristic.
- Psychological experiments crossing a manipulated condition with a participant characteristic, such as stress condition by personality type, to examine interaction effects.
How it works
How it works
The test poses three null hypotheses at the same time. Factor A has no main effect (its level means are equal). Factor B has no main effect (its level means are equal). There is no interaction, meaning the effect of A does not depend on the level of B, and the reverse. Each null hypothesis is tested against its own alternative.
Formula
H_0^A:\ \alpha_i = 0\ \forall i,\quad H_0^B:\ \beta_j = 0\ \forall j,\quad H_0^{AB}:\ (\alpha\beta)_{ij} = 0\ \forall i,jThe total sum of squares is partitioned into the part attributable to Factor A (SS_A), the part attributable to Factor B (SS_B), the interaction part (SS_AB), and residual error (SS_E). Each component is divided by its degrees of freedom to give a mean square. Each factor and interaction mean square is then divided by the mean square error (MS_E) to form an F ratio. A large F ratio means that source of variance is large relative to the within-cell noise. Each F ratio is compared with the F distribution using its numerator and denominator degrees of freedom.
Formula
F_A = \dfrac{MS_A}{MS_E},\quad F_B = \dfrac{MS_B}{MS_E},\quad F_{AB} = \dfrac{MS_{AB}}{MS_E}Each of the three F tests is evaluated at the chosen significance level, conventionally 0.05, and a null hypothesis is rejected when its p-value falls below that level. Examine the interaction first. Marginal means compare the levels of one factor averaged over the levels of the other; cell means are the means of each factor combination. In an interaction plot, roughly parallel lines suggest no interaction, while crossing or clearly diverging lines suggest one. If the interaction is not significant, the main effects can be read from the marginal means. If it is significant, the main effects are conditional, so interpret simple effects (one factor at each level of the other) instead. Post-hoc and simple-effects comparisons need a multiple-comparison correction such as Tukey or Holm. Effect size is reported as partial eta-squared (η²p), the sum of squares of an effect divided by that sum of squares plus the error sum of squares.
Formula
\text{reject } H_0 \text{ if } p < 0.05;\quad \eta^2_p = \dfrac{SS_{\text{effect}}}{SS_{\text{effect}} + SS_E}Common pitfalls
- Interpreting main effects before checking the interaction. A significant A×B interaction means each main effect depends on the level of the other factor, so a main-effect summary can mislead.
- Using Type I (sequential) sums of squares in unbalanced designs. Under Type I, the results depend on the order in which the factors are entered. Choose Type II or Type III deliberately and state which was used.
- Skipping assumption checks. Non-normal residuals or unequal variances can inflate the Type I error rate, most of all when cell sizes are small or unequal; how much it matters depends on the severity of the violation. Consider a robust alternative when violations are marked.
- Reporting p-values alone. When an interaction is significant, report partial eta-squared, the cell means, and an interaction plot.
- Running several one-way ANOVAs across factor combinations instead of one factorial model. This inflates the family-wise error rate and discards the interaction test.
Frequently asked questions
What should I do when the interaction effect is significant?
A significant interaction means the effect of Factor A depends on the level of Factor B, and the reverse, so the main effects alone do not give the full picture. Start by plotting the cell means as an interaction plot to see how the lines cross or diverge. Then run simple-effects analyses, testing one factor separately at each level of the other, and apply a correction for multiple comparisons.
Does the order in which I enter the factors matter?
In a balanced design with equal cell sizes, the order does not change the results. In an unbalanced design, Type I (sequential) sums of squares depend on the order of entry, which can change the conclusions. For unbalanced data, choose Type II or Type III sums of squares explicitly in your software and report your choice.
How is Two-Way ANOVA different from running two separate One-Way ANOVAs?
Two separate one-way ANOVAs test each factor while ignoring the other, do not test the interaction, and use several tests whose errors accumulate. Two-Way ANOVA tests both main effects and their interaction in a single model, so one analysis covers the full cross-classified structure and the interaction test is available.
Which effect size should I report?
Partial eta-squared (η²p) is the usual choice for factorial ANOVA. It gives each effect's sum of squares as a proportion of that effect's sum of squares plus the error sum of squares. Omega-squared (ω²) is generally less biased than partial eta-squared and is often preferred for small samples or when the aim is to generalise beyond the specific study.
Related methods
Sources
Montgomery, D. C. (2017). Design and Analysis of Experiments (9th ed.). Wiley.
ISBN: 978-1119113478