Two-Way ANOVA Calculator

Test effects of two factors.

Enter at least 4 cells (2×2 design minimum)

Examples:

Enter factorial data to perform two-way ANOVA

What Is Two-Way ANOVA?

Two-way ANOVA tests the effects of two independent variables (factors) on a continuous outcome, including their potential interaction.

Questions answered:

  1. Does Factor A affect the outcome?
  2. Does Factor B affect the outcome?
  3. Does the effect of A depend on the level of B (interaction)?

Example: Testing how both teaching method (A: lecture, discussion, hybrid) and class size (B: small, large) affect test scores—and whether teaching method works differently for different class sizes.

Why "Two-Way"?

The data is classified by two categorical factors:

Small ClassLarge Class
Lecture78, 82, 7568, 72, 65
Discussion85, 88, 8280, 78, 82
Hybrid90, 92, 8885, 88, 82

One-way ANOVA uses one factor. Two-way uses two simultaneously.

Main Effects and Interaction

Main Effect of Factor A

The overall effect of Factor A, averaging across all levels of Factor B.

"Do teaching methods differ, ignoring class size?"

Main Effect of Factor B

The overall effect of Factor B, averaging across all levels of Factor A.

"Do class sizes differ, ignoring teaching method?"

Interaction Effect (A × B)

Whether the effect of one factor depends on the level of the other.

"Does the teaching method effect change depending on class size?"

Understanding Interactions

No Interaction

Main effects are additive. If lecture beats discussion by 5 points in small classes, it also beats discussion by 5 points in large classes.

Lines on an interaction plot are parallel.

Interaction Present

The advantage of one factor level depends on the other factor.

"Lecture works well for large classes but poorly for small classes."

Lines cross or diverge in the interaction plot.

Key insight: When interaction is significant, main effects should be interpreted cautiously—the "average" effect obscures conditional effects.

The Statistical Model

Y = μ + αᵢ + βⱼ + (αβ)ᵢⱼ + ε

Where:

  • μ = grand mean
  • αᵢ = effect of Factor A level i
  • βⱼ = effect of Factor B level j
  • (αβ)ᵢⱼ = interaction effect
  • ε = random error

The ANOVA Table

SourceSSdfMSFp
Factor A520226012.4.001
Factor B18011808.6.007
A × B85242.52.0.15
Error5042421
Total128929

Three separate F-tests: one for each main effect, one for interaction.

Degrees of Freedom

  • Factor A: a - 1 (where a = number of A levels)
  • Factor B: b - 1
  • Interaction: (a - 1)(b - 1)
  • Error: N - ab (where N = total observations)
  • Total: N - 1

Interpreting Results

Significant Interaction

Interpret first. Main effects are misleading when interaction exists.

Examine simple effects: the effect of A at each level of B separately.

No Significant Interaction

Interpret main effects directly. Each factor's effect is consistent across levels of the other.

Significant Main Effects

Post-hoc tests (like Tukey HSD) reveal which levels differ.

Effect Sizes

Partial eta-squared (η²p):

η²p = SS_effect / (SS_effect + SS_error)

Proportion of variance explained by each effect after removing other effects.

η²pInterpretation
0.01Small
0.06Medium
0.14Large

Applications

Factorial Experiments

Classic experimental design: manipulate two factors, measure outcome.

Drug study: Drug type × Dosage level Marketing: Ad type × Target demographic

Observational Studies

Classify subjects by two characteristics.

Education: Gender × Socioeconomic status on test scores Health: Age group × Exercise level on blood pressure

Quality Control

Manufacturing: Machine × Shift on defect rates Agriculture: Fertilizer type × Irrigation method on yield

Balanced vs. Unbalanced Designs

Balanced

Equal n in all cells. Simplest analysis, most powerful, orthogonal effects.

Unbalanced

Unequal cell sizes. Effects may not be orthogonal—order of entry matters.

Type I SS: Sequential, order-dependent Type II SS: Each effect adjusted for other main effects (not interaction) Type III SS: Each effect adjusted for all other effects (most common default)

Assumptions

Independence

Observations are independent within and across all cells.

Normality

Residuals are normally distributed, OR sample sizes are adequate.

Homogeneity of Variance

Variances are equal across all cells (not just factor levels).

Check: Levene's test or visual inspection of residual plots.

No Missing Cells

Each combination of factor levels should have observations.

Fixed vs. Random Factors

Fixed Factors

Levels are specifically chosen and exhaustive.

"These three teaching methods are what we care about."

Most common in research applications.

Random Factors

Levels are randomly sampled from a larger population.

"These five teachers represent all possible teachers."

Requires different F-ratio calculations (mixed models).

Interaction Plots

Visualize factor relationships:

  • X-axis: Levels of Factor A
  • Y-axis: Mean response
  • Separate lines: Levels of Factor B

Parallel lines: No interaction Non-parallel lines: Interaction present Crossing lines: Strong disordinal interaction

Post-Hoc Procedures

For significant main effects (without interaction):

  • Tukey HSD for all pairwise comparisons
  • Bonferroni for selected comparisons

For significant interaction:

  • Simple effects analysis (effect of A at each B level)
  • Simple comparisons within cells

Common Mistakes

Ignoring Interaction

Reporting main effects when interaction is significant gives incomplete or misleading conclusions.

Wrong Error Term

In designs with random factors or repeated measures, error terms differ.

Unbalanced Analysis

Not specifying appropriate SS type for unbalanced data.

Over-Interpretation

Many non-significant interactions exist because power to detect them is limited.

Reporting Results

APA format:

"A 3 × 2 between-subjects ANOVA revealed significant main effects of teaching method, F(2, 24) = 12.4, p = .001, η²p = .51, and class size, F(1, 24) = 8.6, p = .007, η²p = .26. The interaction was not significant, F(2, 24) = 2.0, p = .15. Post-hoc Tukey tests showed hybrid instruction (M = 87.5) outperformed both lecture (M = 73.3, p < .001) and discussion (M = 82.5, p = .03)."

Historical Context

Two-way ANOVA emerged from Ronald Fisher's work in agricultural experimentation at Rothamsted in the 1920s-1930s.

Factorial designs—testing multiple factors simultaneously—proved more efficient than one-factor-at-a-time experiments. The interaction concept was particularly revolutionary: it formalized how factors could work differently in combination than alone.

Related Calculations

Summary

Two-way ANOVA tests main effects of two factors and their interaction on a continuous outcome. Significant interaction indicates that one factor's effect depends on the other factor—in such cases, examine simple effects rather than main effects. The analysis partitions total variance among Factor A, Factor B, A×B interaction, and error. Report all three F-tests, effect sizes (partial η²), and appropriate post-hoc tests. Interaction plots provide essential visualization of factor relationships.