Two-Way ANOVA
Hypothesis TestingTests the effects of two categorical factors and their interaction on a continuous dependent variable, partitioning variance into main effects and interaction effects.
When to Use
Use this test when you have a continuous outcome and two categorical grouping variables, and you want to know the effect of each factor as well as whether the factors interact. For example, testing whether drug type and dosage level jointly affect tumour size, or whether gender and teaching method interact to influence exam scores.
Assumptions
- The dependent variable is continuous.
- Observations are independent.
- The dependent variable is approximately normally distributed within each cell (combination of factor levels).
- Homogeneity of variances across all cells.
- For unbalanced designs, Type III sums of squares should be used.
Required Inputs
| Input | Type | Notes |
|---|---|---|
| Dependent Variable | Numeric | Continuous outcome variable |
| Factor 1 | Categorical | First grouping factor |
| Factor 2 | Categorical | Second grouping factor |
Output Metrics
| Metric | What it means |
|---|---|
| Factor A — DF | Degrees of freedom for the first main effect. |
| Factor A — SS | Sum of squares for the first main effect. |
| Factor A — MS | Mean square for the first main effect. |
| Factor A — F | F-statistic for the first main effect. |
| Factor A — Pr > F | P-value for the first main effect. |
| Factor B — DF | Degrees of freedom for the second main effect. |
| Factor B — SS | Sum of squares for the second main effect. |
| Factor B — MS | Mean square for the second main effect. |
| Factor B — F | F-statistic for the second main effect. |
| Factor B — Pr > F | P-value for the second main effect. |
| A*B Interaction — DF | Degrees of freedom for the interaction between Factor A and Factor B. |
| A*B Interaction — SS | Sum of squares for the interaction term. |
| A*B Interaction — MS | Mean square for the interaction term. |
| A*B Interaction — F | F-statistic for the interaction between Factor A and Factor B. |
| A*B Interaction — Pr > F | P-value for the interaction effect. |
| Partial Eta-Squared | Effect size for each factor and interaction. Thresholds: small (0.01), medium (0.06), large (0.14). |
| Means Type | Balanced designs report observed cell means; unbalanced designs report LS means (estimated marginal means). |
| Means Table | Per-cell means with standard error and confidence limits using the selected means type. |
| Simple Effects | Effect of one factor within each level of the other factor. |
| Post-Hoc Comparisons | Pairwise comparisons of means with multiplicity-adjusted p-values. |
Interpretation
- Always check the interaction effect first. If the A*B interaction is significant, the effect of one factor depends on the level of the other factor.
- When the interaction is significant, main effects should be interpreted cautiously. Instead, examine simple effects: the effect of Factor A at each level of Factor B (and vice versa).
- When the interaction is not significant, main effects can be interpreted directly as average effects across levels of the other factor.
- Partial eta-squared tells you the proportion of variance explained by each effect after removing variance due to other effects.
- Post-hoc pairwise comparisons help identify which specific cell-level effects differ.
- For balanced designs, means reflect observed cell averages; for unbalanced designs, means reflect model-based LS means to avoid imbalance bias.
Common Pitfalls
- Interpreting main effects when a significant interaction is present can be misleading. A main effect might appear significant on average but only exist at certain levels of the other factor.
- Unbalanced designs (unequal cell sizes) require Type III sums of squares. Type I sums of squares give different results depending on the order factors are entered.
- Empty cells (combinations of factor levels with no data) make interaction effects non-estimable.
- Very small cell sizes reduce power and make the normality assumption harder to verify.
How It Works
- Compute observed cell means and assess design balance from per-cell sample counts.
- If the design is balanced, use observed cell means; if unbalanced, derive LS means (estimated marginal means) from model predictions.
- Partition the total sum of squares into components: Factor A main effect, Factor B main effect, A*B interaction, and residual error.
- Divide each component by its degrees of freedom to get mean squares, then compute F-ratios by dividing each mean square by the error mean square.
- Compare each F-ratio to the F-distribution to obtain p-values for the main effects and interaction.
Citations
References
- Fisher, R. A. (1925). Statistical Methods for Research Workers. Oliver & Boyd.