Two-Way ANOVA Calculator
car::Anova(model, type=3) or SPSS General Linear Model).
Set the number of levels for each factor, then click Build grid. Enter one value per cell (each cell represents a single observation for that combination of factor levels).
What Is a Two-Way ANOVA?
A two-way ANOVA (also called a two-factor ANOVA or factorial ANOVA) tests how two categorical independent variables and their interaction simultaneously affect one continuous dependent variable. Where a one-way ANOVA calculator tests a single null hypothesis, the two-way version tests three at once: one for each factor's main effect and one for the A×B interaction.
That interaction term is what makes the two-way design valuable. Running two separate one-way ANOVAs on the same data misses it entirely and wastes the information available in a factorial experiment. The two-way test is part of the broader toolkit covered in hypothesis testing.
When to Use Two-Way ANOVA
| Use two-way ANOVA when… | Instead consider… |
|---|---|
| You have 2 categorical independent variables | One-way ANOVA if you have 1 factor |
| You want to test whether the two factors interact | Separate one-way ANOVAs (less efficient; misses interaction) |
| The dependent variable is continuous | Chi-square test if the DV is categorical |
| Observations are independent | Repeated-measures ANOVA if subjects appear in multiple cells |
| Each factor has 2+ levels, equal n per cell | T-test calculator if one factor has exactly 2 levels and you don't need an interaction test |
The Three Null Hypotheses
A two-way ANOVA tests all three simultaneously:
Two-Way ANOVA Formula and ANOVA Table
Each F-statistic is computed as MSeffect / MSerror. The error row (also called the within-groups or residual row) is the denominator for all three F-tests. One thing that trips people up: the Total row carries SStotal and dftotal only — it has no MS or F value.
| Source | SS | df | MS | F |
|---|---|---|---|---|
| Factor A | SSA | a − 1 | SSA / (a−1) | MSA / MSE |
| Factor B | SSB | b − 1 | SSB / (b−1) | MSB / MSE |
| A × B | SSAB | (a−1)(b−1) | SSAB / [(a−1)(b−1)] | MSAB / MSE |
| Error | SSE | ab(n−1) | SSE / [ab(n−1)] | — |
| Total | SST | abn − 1 | — | — |
a = number of levels of Factor A • b = number of levels of Factor B • n = observations per cell (balanced)
Why only the right tail of the F distribution?
F = variancebetween / variancewithin. We reject the null only when the between-group variance is larger than the within-group variance, which produces a large F in the right tail. A low F value means groups are more similar than chance would predict — that is not evidence of a treatment effect. The F distribution starts at zero and extends rightward, so the rejection region sits entirely in the right tail. You can look up the critical F value in the F-distribution table.
Step-by-Step Worked Example
Drug Dosage × Patient Gender on Response Time
Raw data by cell:
| Cell | Values | Cell mean |
|---|---|---|
| Low dose, Male | 85, 90, 88, 92, 87 | 88.4 |
| Low dose, Female | 78, 82, 80, 85, 79 | 80.8 |
| High dose, Male | 72, 75, 74, 70, 73 | 72.8 |
| High dose, Female | 69, 71, 70, 72, 68 | 70.0 |
Computed ANOVA table:
| Source | SS | df | MS | F | p |
|---|---|---|---|---|---|
| Dosage (A) | 2016.20 | 1 | 2016.20 | 93.80 | < .001 |
| Gender (B) | 338.45 | 1 | 338.45 | 15.74 | < .001 |
| Dosage × Gender | 51.20 | 1 | 51.20 | 2.38 | .140 |
| Error | 343.00 | 16 | 21.44 | — | — |
| Total | 2748.85 | 19 | — | — | — |
Interpretation: The interaction is not significant (F = 2.38, p = .140), so we can interpret the main effects directly. Dosage has a significant main effect (F = 93.80, p < .001): high dose produces lower response times overall. Gender also has a significant main effect (F = 15.74, p < .001): females show lower response times overall. Because each factor has only two levels and the interaction is non-significant, no Tukey HSD post-hoc test is needed here.
Load these exact values into the calculator above to reproduce the table and verify the figures.
How to Interpret Two-Way ANOVA Results
Check the interaction effect first
This is the most important step. If A×B is significant (p < α), do not interpret the main effects as global statements. The effect of Factor A differs depending on which level of Factor B you're looking at. Run simple main effects analysis instead: test the effect of A at each level of B separately, and apply Bonferroni correction to control the family-wise error rate. Main effects can be numerically significant but deeply misleading when the interaction is significant — a drug that "works overall" may work only for one age group.
Interpret main effects (when interaction is not significant)
If the interaction is not significant, main effects are interpretable directly at the marginal mean level. Any main effect with 3 or more levels requires a post-hoc test to identify which specific groups differ. Tukey HSD is the standard choice for balanced designs; see the Tukey HSD table for critical values.
Report effect sizes
η² (eta-squared) = SSeffect / SStotal gives each effect's share of total variance. Partial η² = SSeffect / (SSeffect + SSerror) is the standard for publication because it allows cross-study comparison. Cohen's benchmarks for partial η²: small = 0.01, medium = 0.06, large = 0.14. The effect size calculator can confirm these values.
Read the interaction plot
An interaction plot places one factor on the x-axis with separate lines for each level of the other factor. Parallel lines indicate no interaction — both factors operate independently. Converging or crossing lines signal an interaction. Crossing lines (a "disordinal" interaction) mean the factors reverse each other's effect at different levels. When an interaction is significant, the plot is the clearest way to communicate what it means.
Post-Hoc Tests After Two-Way ANOVA
Post-hoc tests are needed when a factor with 3 or more levels is significant, or when a significant interaction requires simple main effects analysis.
| Test | When to use |
|---|---|
| Tukey HSD | Significant main effect with 3+ levels, balanced design, homogeneous variances. Find critical values in the Tukey q table. |
| Bonferroni correction | Simple main effects analysis after a significant interaction; multiply individual p-values by the number of comparisons. Use the Bonferroni calculator. |
| Games-Howell | Main effects or simple effects when cell variances are unequal (heteroscedastic); does not assume equal variances. |
Assumptions of Two-Way ANOVA
Two-way ANOVA rests on five assumptions. The fifth in particular can trip researchers up when variances differ between cells.
Balanced vs. Unbalanced Designs
A balanced design has the same number of observations in every cell. All three types of sums of squares (Type I, II, III) produce identical results, which is why the computations in this calculator are straightforward.
An unbalanced design has unequal cell sizes. Type I SS is order-dependent and inappropriate for this case. You must use Type III SS, which is the default in SPSS (General Linear Model) and available in R via car::Anova(model, type=3). Never apply the formulas in this calculator to unbalanced data.
The same principle extends to interpreting sums of squares: for balanced data the distinction between types doesn't matter; for unbalanced data, using the wrong type produces incorrect F-statistics and p-values for each effect.
Frequently Asked Questions
What is a two-way ANOVA?
What does the interaction effect mean?
How do I read the two-way ANOVA table?
What are the assumptions of two-way ANOVA?
What post-hoc tests should I use after a significant two-way ANOVA?
What is the difference between balanced and unbalanced two-way ANOVA?
car::Anova(type=3) or SPSS General Linear Model with Type III SS for unbalanced designs.