Two-Way ANOVA Calculator | Factorial Design with Interaction Term
Perform a two-way analysis of variance for a factorial design with up to 4 levels per factor. Computes sum of squares, degrees of freedom, mean squares, F-statistics, and p-values for factor A, factor B, their interaction A×B, and error. Reports eta-squared effect sizes and overall model fit.
Design Setup
Data Entry (one observation per cell)
| Factor A \ Factor B | Factor B 1 | Factor B 2 | Factor B 3 | Row mean |
|---|---|---|---|---|
| Factor A 1 | — | |||
| Factor A 2 | — | |||
| Factor A 3 | — | |||
| Col mean | — | — | — | — |
What Is the Two-Way ANOVA Calculator | Factorial Design with Interaction Term?
Two-way ANOVA tests whether two categorical factors each have a significant effect on a continuous outcome. Factor A (rows) and Factor B (columns) each get their own F-statistic comparing that factor's mean square to the residual error mean square. Without replication (one observation per cell), the interaction term is confounded with error; with replication you can estimate the A×B interaction term separately.
Formula
F_A = MS_A / MS_Error, F_B = MS_B / MS_Error; SS_A = b·Σᵢ(ȳᵢ.−ȳ..)², SS_B = a·Σⱼ(ȳ.ⱼ−ȳ..)², SS_Error = SS_Total − SS_A − SS_B
How to Use
- 1
Choose the number of levels for Factor A (rows) by clicking 2, 3, or 4 under the Factor A section. Then do the same for Factor B (columns).
- 2
Enter descriptive labels for Factor A and Factor B — for example, "Drug Type" and "Dosage Level" or "Temperature" and "Humidity".
- 3
Click on the preset buttons to load example datasets if you want to see how the calculator works before entering your own data.
- 4
Fill in the data grid. Each cell y_ij contains a single numeric observation for the combination of Factor A level i and Factor B level j.
- 5
Click Run Two-Way ANOVA. The row and column means appear in the grid margins, and the ANOVA table shows below.
- 6
Read the ANOVA table: for each factor, check whether F is large and p < 0.05 to determine statistical significance. The significance stars (*, **, ***) indicate confidence levels.
- 7
Interpret effect sizes η²: a large η² for Factor A means A explains a large share of the outcome variance, beyond what is significant alone.
Set the number of levels for each factor, label your factors, enter cell values in the grid, and click Run Two-Way ANOVA.
Example Calculation
Fertilizer (3 types) × Irrigation (3 levels): data = [[12,15,18],[14,17,20],[10,13,16]]. Grand mean = 15. Row means = [15, 17, 13]. Column means = [12, 15, 18]. SS_A = 3·[(15−15)²+(17−15)²+(13−15)²] = 3·8 = 24. SS_B = 3·[(12−15)²+(15−15)²+(18−15)²] = 3·18 = 54. SS_Total = 60. SS_Error = 60−24−54 = −18? Wait — in this perfect additive dataset, SS_Error = 0, indicating a perfectly additive (no noise) design. Real data will have non-zero error.
Understanding Two-Way ANOVA | Factorial Design with Interaction Term
Two-Way ANOVA Table Structure
The ANOVA table partitions total variance into components attributable to each factor and the residual error. Without replication (one observation per cell), there is no separate interaction term — SS_Error captures both residual and interaction.
| Source | SS formula | df | MS | F statistic |
|---|---|---|---|---|
| Factor A (rows) | b·Σᵢ(ȳᵢ. − ȳ..)² | a − 1 | SS_A / df_A | MS_A / MS_Error |
| Factor B (cols) | a·Σⱼ(ȳ.ⱼ − ȳ..)² | b − 1 | SS_B / df_B | MS_B / MS_Error |
| Error (residual) | SS_Total − SS_A − SS_B | (a−1)(b−1) | SS_E / df_E | — |
| Total | ΣΣ(yᵢⱼ − ȳ..)² | N − 1 = ab − 1 | — | — |
With replication (n>1 per cell): SS_Interaction = SS_Total − SS_A − SS_B − SS_Error(within cell), with df = (a−1)(b−1).
Effect Size η² Interpretation
Eta-squared (η²) measures the proportion of total variance explained by each factor. Unlike the p-value, it does not depend on sample size.
| η² range | Effect size | Interpretation | Example |
|---|---|---|---|
| < 0.01 | Negligible | Factor explains <1% of variance | Measurement noise, trivial difference |
| 0.01 – 0.06 | Small | Detectable with large samples | Subtle treatment effects in medicine |
| 0.06 – 0.14 | Medium | Practically noticeable | Educational intervention differences |
| > 0.14 | Large | Substantial, obvious effect | Strong drug treatment, major environmental factor |
Partial η² (η²_p = SS_A / (SS_A + SS_Error)) is preferred in multi-factor designs; it equals η² in two-factor designs without replication.
Assumptions and Applications
- ▸Independence assumption: Each observation must be independent. In a drug × dose experiment, each cell must contain a different subject; repeated measurements violate this and require repeated-measures ANOVA instead.
- ▸Normality assumption: The response variable within each cell should be approximately normally distributed. Robustness increases with sample size; with n per cell ≥ 10, mild non-normality is acceptable.
- ▸Homoscedasticity (equal variances): With replication, all cells should have similar within-cell variance. Bartlett's or Levene's test can check this. Without replication, this assumption applies to the row × column residuals.
- ▸Agricultural experiments: The original application of two-way ANOVA (Fisher, 1920s): testing fertilizer type × irrigation level on crop yield, controlling for block effects in randomized block designs.
- ▸Medical research: Drug type × dose level factorial designs efficiently test both main effects and their interaction in a single experiment with fewer subjects than running separate one-way ANOVAs.
- ▸Manufacturing quality control: Operator × machine factorial designs identify whether product quality variation is due to machine differences, operator differences, or both — guiding targeted training or maintenance.
- ▸Psychology and education: Teaching method × student ability level designs reveal whether a new curriculum is universally better or only helps certain student groups (a crossover interaction).
Frequently Asked Questions
What is the difference between one-way and two-way ANOVA?
One-way ANOVA tests a single categorical factor with multiple levels — for example, comparing three drug treatments. Two-way ANOVA tests two factors simultaneously. It is more efficient than running two separate one-way ANOVAs because it uses all the data to estimate both effects, and with replication it can also detect an interaction effect: whether the impact of Factor A differs depending on which level of Factor B is present.
Why can't I estimate the interaction effect without replication?
With exactly one observation per cell (no replication), you have a×b data points and a×b − 1 degrees of freedom for total variation. The main effects consume (a−1)+(b−1) degrees of freedom, leaving (a−1)(b−1) for error. There is no remaining variation to estimate the interaction A×B separately — it is fully confounded with the error term. You need at least n≥2 observations per cell to separate SS_Interaction from SS_Error(within).
What does a significant interaction effect mean?
An interaction effect (with replication) means the effect of Factor A depends on the level of Factor B. For example, if Drug A is better than Drug B at a low dose but worse at a high dose, there is an A×B interaction. When you have a significant interaction, the main effects alone are misleading — you must report the cell means and describe the nature of the interaction (ordinal vs. disordinal/crossover).
How is the p-value computed for the F-statistic?
The p-value is P(F > observed F | H₀ true), where the F-distribution has df₁ and df₂ degrees of freedom. This calculator uses the regularized incomplete beta function: P(F > f; d₁, d₂) = I_{d₂/(d₂+d₁f)}(d₂/2, d₁/2). This is the exact p-value, not a lookup-table approximation.
What are the assumptions of two-way ANOVA?
The key assumptions are: (1) Independence — each observation is from a separate experimental unit; (2) Normality — the response within each cell is approximately normally distributed (less critical with large n per cell); (3) Homoscedasticity — the variance within each cell is equal across all cells (with replication). Violations can be addressed with data transformation (e.g., log transform) or non-parametric alternatives like the Friedman test for randomized block designs.
You Might Also Like
Explore 360+ Free Calculators
From math and science to finance and everyday life — all free, no account needed.