How to Run a Two-Way ANOVA

Enter a cell grid of observations, choose the replication design, review the ANOVA table and effect sizes, and interpret the interaction and simple effects correctly.

  1. 1. Choose the input mode and design: Pick Raw data if you have individual observations per cell, which enables the full diagnostic set. Pick Summary statistics if you only have n, mean, and SD per cell — the ANOVA table, effect sizes, post-hoc comparisons, and interaction plot still work. Then choose With replication when each cell has more than one observation, or Without replication when each cell has exactly one.
  2. 2. Name the factors and enter the data: Enter a name for each factor (e.g. Treatment, Gender) and label each level in the grid headers and row labels. Then enter the values in each cell. In raw mode, values can be separated by commas or spaces. In summary mode, enter n, mean, and SD per cell. Up to 8 levels per factor. Click Load example to populate a common two-factor design.
  3. 3. Set α and the post-hoc method: Choose α from the presets (0.10, 0.05, 0.01) or enter a custom value. Choose Tukey HSD for equal-variance post-hoc comparisons on the marginal means, or Bonferroni or Holm for more conservative approaches. The post-hoc method applies to whichever main effects come out significant.
  4. 4. Read the ANOVA table and effect sizes: The ANOVA table shows SS, df, MS, F, and p for Factor A, Factor B, the A×B interaction, and the error term. Check partial η² and ω² for each effect. The interaction plot shows whether the pattern of one factor changes across levels of the other — inspect it before interpreting the main effects.
  5. 5. Interpret the interaction and simple effects: If the interaction is significant, look at the simple effects — the effect of one factor within each level of the other — and describe the pattern shown in the interaction plot. If the interaction is not significant, examine the main effects. Follow any significant main effect with the post-hoc comparisons to identify which levels differ.
  6. 6. Review the diagnostics and report: Check Brown-Forsythe for homogeneity of variance, Shapiro-Wilk on the residuals and the Q-Q plot for normality, and the box plots for outliers. Use the APA-style summary line as the basis for your write-up, and add the substantive interpretation in the context of the research question.

What Is a Two-Way ANOVA?

A two-way ANOVA tests how two categorical factors affect a continuous outcome. It answers three questions at once: does Factor A matter on its own, does Factor B matter on its own, and do the two factors interact so that the effect of one depends on the level of the other. It is the natural next step after a one-way ANOVA when you have two explanatory variables instead of one.

A typical design: Teaching Method × Study Environment → Exam Score. Method has two or more levels (Lecture, Lab). Environment has two or more levels (Quiet, Noisy). The outcome is a numeric score. A two-way ANOVA tells you whether the method matters, whether the environment matters, and whether the method's effect depends on the environment.

What the Three Tests Mean

Main effect of Factor A — do the level means of A differ when you average across every level of B? Equivalent to asking whether Factor A matters on its own.

Main effect of Factor B — same question, swapped.

Interaction A×B — does the effect of A change depending on which level of B you are in? A significant interaction means the pattern across one factor is not constant across the other.

A key point: when the interaction is significant, the main effects can be misleading. The average of A across levels of B can hide two opposite patterns that cancel each other out. In that case, look at the interaction plot and the simple effects, not at the main effects in isolation.

Formula and Degrees of Freedom

The analysis partitions total variation into four components:

SS_Total = SS_A + SS_B + SS_AB + SS_Error

  • SS_A — variation explained by Factor A (between level means and the grand mean).
  • SS_B — variation explained by Factor B.
  • SS_AB — variation explained by the A×B interaction (how much the cell means deviate from a purely additive model).
  • SS_Error — within-cell residual variation.

Degrees of freedom: df_A = a − 1, df_B = b − 1, df_AB = (a − 1)(b − 1), df_Error = N − ab for the standard full factorial model with all cells represented, where a is the number of levels of A, b is the number of levels of B, and N is the total number of observations. Each SS is divided by its df to give MS, and each F statistic is the ratio of its MS to MS_Error. The p-value is the upper-tail probability of the F distribution with that numerator df and the error df.

With vs Without Replication

With replication — each cell of the factor grid has more than one observation. The A×B interaction can be estimated separately from pure error and tested. This is the common case.

Without replication — one observation per cell. The A×B interaction cannot be estimated separately from the residual term, so the interaction is not tested. Both main effects can still be tested under the standard no-replication model. The design is used when running the study more than once per cell is impractical.

Balanced vs Unbalanced Designs

Balanced means every cell has the same number of observations. Unbalanced means cell sizes differ. Both are supported. With an unbalanced design, the exact sums-of-squares decomposition depends on the type of sums of squares used (Type I, II, or III), and different software can produce different F values for the same data. The calculator uses a defined SS decomposition and reports the residual df from the actual observations. For unbalanced designs, confirm your analysis plan matches the SS type you intend to report.

Cell, Marginal, and Grand Means

Three kinds of means feed the ANOVA calculations:

  • Cell mean — the mean of a single cell (a specific combination of Factor A and Factor B).
  • Marginal mean — the mean of a level of one factor, averaged across all levels of the other. Row means for Factor A, column means for Factor B.
  • Grand mean — the mean of every observation, ignoring factors.

Between-group variation is built from cell means around the grand mean, then split into the parts explained by each factor and their interaction.

Interaction and Simple Effects

The interaction plot shows cell means of Factor A on the horizontal axis, with a separate line per level of Factor B. Parallel lines suggest no interaction — the effect of A is the same at every level of B. Non-parallel lines, especially crossing lines, suggest an interaction.

When the interaction is significant, the correct follow-up is simple effects: the effect of one factor within each level of the other. Does Factor A matter at level B1? At level B2? Simple effects answer those questions directly and are reported by the calculator when the interaction is significant.

Post-Hoc Tests and Effect Sizes

When a main effect is significant, the omnibus F tells you that factor's level means differ, not which levels differ. The calculator runs pairwise comparisons on the marginal means using Tukey HSD, Bonferroni, or Holm, with adjusted p-values and confidence intervals. Tukey is the standard for equal-variance comparisons and is generally more powerful. Bonferroni is conservative but simple. Holm is a step-down version that is uniformly more powerful than Bonferroni while still controlling the familywise error rate.

Effect sizes describe how large an effect is. The calculator reports partial η² for each effect (SS_effect / (SS_effect + SS_Error)), which is the standard in factorial ANOVA, and ω² (omega squared) as a less biased alternative. Conventional partial η² benchmarks (~0.01 small, ~0.06 medium, ~0.14 large) are orientation only — the meaningful size depends on the field and the question.

Assumptions and Diagnostics

Three assumptions matter:

  • Independence — observations are independent within and across cells. This is a design property and cannot be verified from the numbers.
  • Normality — residuals within cells are approximately normal. Shapiro-Wilk on the residuals and a normal Q-Q plot check this when raw data are available.
  • Homogeneity of variance — cell variances are approximately equal. Brown-Forsythe (median-centered Levene) across cells tests this.

The calculator also draws box plots per cell (with Tukey 1.5×IQR outlier flagging, values never removed) and a residuals-vs-fitted plot to check constant variance. Passing a diagnostic test does not by itself prove the assumption holds — use the plots and the diagnostics together with subject-matter judgement.

How to Interpret the Result

  1. Check the interaction first. If A×B is significant, interpret simple effects and the interaction plot, not the main effects in isolation.
  2. If the interaction is not significant, examine the main effects. A significant main effect means the factor matters on average.
  3. Follow significant main effects with post-hoc comparisons to identify which levels differ.
  4. Review effect sizes (partial η², ω²) to judge practical magnitude.
  5. Check the diagnostics — Brown-Forsythe, Q-Q plot, box plots, residuals-vs-fitted.
  6. Report the result using the APA-style summary the calculator generates.

Common Mistakes

  • Interpreting main effects when the interaction is significant. A significant A×B means the main effect of A changes across levels of B. Report simple effects instead.
  • Running post-hoc tests without a significant effect. Post-hoc comparisons are follow-ups to a significant omnibus main effect. Preplanned contrasts are a separate approach.
  • Skipping the interaction plot. A p-value tells you whether the interaction is significant, not what shape it takes. Look at the plot before interpreting.
  • Using one observation per cell and expecting an interaction test. Interaction is not tested without replication.
  • Ignoring SS type in unbalanced designs. Different SS types can produce different F values. Check which SS type your analysis plan uses.
  • Reporting p-values without effect sizes. Statistical significance and practical magnitude are separate questions.
  • Reading a non-significant result as proof of no effect. Failing to reject the null means the data did not provide sufficient evidence at the chosen α — not that the effect is absent.
  • Applying repeated-measures methods to independent-group data, or vice versa. If the same subject contributes to multiple cells, the design calls for a repeated-measures or mixed ANOVA.

APA-Style Reporting

A significant main effect: There was a significant main effect of Treatment, F(2, 24) = 5.42, p = .011, partial η² = .31.

A significant interaction: There was a significant Treatment × Condition interaction, F(2, 24) = 4.18, p = .028, partial η² = .26.

A non-significant effect: The main effect of Gender was not significant, F(1, 24) = 0.84, p = .369, partial η² = .03.

State the design (with or without replication), the factors and levels, cell sample sizes, and the result for each effect. When the interaction is significant, report the simple effects and describe the pattern shown in the interaction plot.

Frequently Asked Questions

Q: What is a two-way ANOVA?

A two-way ANOVA tests how two categorical factors affect a continuous outcome. It produces three tests: the main effect of Factor A, the main effect of Factor B, and the A×B interaction. Each answers a different question — whether each factor matters on its own, and whether the effect of one depends on the level of the other.

Q: What is the difference between one-way and two-way ANOVA?

One-way ANOVA has a single categorical factor. Two-way ANOVA has two factors and can test the interaction between them. If you have two factors and want to know whether they interact, two-way is the correct design. The two tests share the same F and p-value framework, but the two-way case adds the interaction term.

Q: What is a main effect?

A main effect is the effect of one factor averaged across the levels of the other. The Factor A main effect asks whether the level means of A differ when you collapse across Factor B. It is tested with an F statistic from the ratio of MS_A to MS_Error, and reported with a p-value and partial η².

Q: What is an interaction effect?

An interaction effect (A×B) asks whether the effect of one factor depends on the level of the other. A significant interaction means the pattern of A's effect is not the same at every level of B. When the interaction is significant, main effects can be misleading — average across levels can hide opposite patterns that cancel out — so the interaction plot and simple effects should be examined instead.

Q: What is the difference between with and without replication?

With replication means each cell of the factor grid has more than one observation, so the A×B interaction can be estimated separately from pure error and tested. Without replication — one observation per cell — the interaction cannot be estimated separately from the residual term, so the interaction is not tested. Both main effects can still be tested in the no-replication model.

Q: How are degrees of freedom calculated in two-way ANOVA?

For a balanced replicated factorial design: df_A = a − 1, df_B = b − 1, df_AB = (a − 1)(b − 1), df_Error = N − ab, where a and b are the number of levels and N is the total sample size. Without replication, the interaction df is pooled with the residual term. In unbalanced designs, the SS decomposition and the main-effect F tests depend on the type of sums of squares used.

Q: Can two-way ANOVA handle unequal sample sizes?

Yes. Unequal cell sizes are supported and common in real studies. The sums of squares weight each cell mean by its sample size, so the marginal means and F statistics account for unequal n. In unbalanced designs, different types of sums of squares (Type I, II, III) can produce different F values for the same data, so check that the calculator's SS type matches your analysis plan.

Q: What are cell means, marginal means, and the grand mean?

The cell mean is the mean of a single cell — one combination of Factor A and Factor B. The marginal mean is the mean of a level of one factor, averaged across all levels of the other. The grand mean is the mean of every observation. Between-group variation is built from cell means around the grand mean, then split into the parts explained by each factor and their interaction.

Q: What post-hoc test should I use after a significant main effect?

Tukey HSD is the standard for equal-variance pairwise comparisons on marginal means and is generally more powerful. Bonferroni is conservative and simple. Holm is a step-down version of Bonferroni that is uniformly more powerful while still controlling the familywise error rate. The calculator applies the chosen method to each significant main effect.

Q: What is partial η² and how do I interpret it?

Partial η² = SS_effect / (SS_effect + SS_Error). It represents the proportion of variance explained by the effect, partialling out the other effects and error, and it is the standard effect size in factorial ANOVA. Conventional benchmarks (~0.01 small, ~0.06 medium, ~0.14 large) are orientation only — the meaningful size depends on the field and the question.

Q: What assumptions does two-way ANOVA make?

Independence of observations within and across cells, approximate normality of residuals within cells, and homogeneity of variance across cells. Independence is a design property and cannot be verified from the numbers. Normality matters most for small samples. Variance homogeneity matters most when cell sizes are unequal. The calculator reports Brown-Forsythe for the variance assumption and Shapiro-Wilk with a Q-Q plot for residual normality when raw data are available.

Q: How do I report a two-way ANOVA in APA format?

State the design (with or without replication), the factors and levels, and the cell sample sizes. For each significant effect, report F, degrees of freedom, p-value, and partial η². When the interaction is significant, report simple effects and describe the interaction plot. A typical line for a significant main effect reads: F(2, 24) = 5.42, p = .011, partial η² = .31. The calculator generates an APA-style summary you can adapt directly.

Loaded shared calculation