Two-Way ANOVA Variance (Formula & Examples)

Two-way ANOVA tests how two categorical factors relate to a numeric outcome. It splits the outcome’s total variation into variation linked to each factor, their interaction, and leftover error. Divide each effect’s mean square by the error mean square to get an F-statistic. Replication within each factor combination lets you estimate interaction and error separately.

If you are planning an experiment or reading an ANOVA table, the key is to connect each number to your research question. You need to know what the factors are, whether their effects change together, and how much unexplained variation remains. The guide below walks through the design, formulas, a worked example, and ways to report results.

Two-Way ANOVA Overview: Factors, Interaction, and Design Requirements

Two-way ANOVA compares average outcomes across levels of two categorical factors. It can test each factor’s main effect and whether the effect of one factor changes across levels of the other. The outcome must be quantitative, and the design must support a meaningful estimate of error.

A study might test how teaching method and class size relate to a numeric test score. Teaching method and class size are the factors; their categories are levels. The test score is the response, or outcome.

The model for a standard fixed-effects two-way ANOVA is:

[ Y_{ijk}=\mu+\alpha_i+\beta_j+(\alpha\beta){ij}+\varepsilon ]

Here, (Y_{ijk}) is one observation in factor A’s level (i), factor B’s level (j), and replicate (k). The terms represent the overall mean, factor A effect, factor B effect, their interaction, and random error.

An interaction means the association between one factor and the outcome differs across levels of the other factor. For example, one teaching method might relate to higher scores in small classes but not in large classes. This is not just a technical detail: it can change the practical meaning of the main effects.

Replication means there is more than one observation for a factor-level combination, also called a cell. In a standard replicated design, replication helps estimate within-cell error separately from interaction. With just one observation per cell, the usual interaction and error cannot be estimated separately without added assumptions or an external error estimate.

Before calculating anything, specify the outcome, both factors, their levels, the number of observations in each cell, and whether the factors are fixed or random. In many introductory studies, researchers choose the factor levels and treat them as fixed.

Variance Formula and Worked Example: Sums of Squares, Degrees of Freedom, and F-Tests

Two-way ANOVA measures variation with sums of squares (SS), then divides each SS by its degrees of freedom to get a mean square (MS). Each F-statistic compares an effect’s MS with the error MS. In a balanced design, this process partitions total variation among both factors, their interaction, and error.

For a balanced design, let factor A have (a) levels, factor B have (b) levels, and each cell have (n) observations. The total sample size is (N=abn). A dot in a mean’s subscript indicates averaging across that index. For example, (\bar Y_{ij.}) is the mean for cell (i,j).

The sums of squares are:

[ SS_T=\sum_{ijk}(Y_{ijk}-\bar Y_{…})^2 ]

[ SS_A=bn\sum_i(\bar Y_{i..}-\bar Y_{…})^2 ]

[ SS_B=an\sum_j(\bar Y_{.j.}-\bar Y_{…})^2 ]

[ SS_{AB}=n\sum_{ij}(\bar Y_{ij.}-\bar Y_{i..}-\bar Y_{.j.}+\bar Y_{…})^2 ]

[ SS_E=\sum_{ijk}(Y_{ijk}-\bar Y_{ij.})^2 ]

For this balanced model, (SS_T=SS_A+SS_B+SS_{AB}+SS_E). In plain terms, total variation is split into variation linked to A, B, their interaction, and differences among observations within the same cell.

Worked example

Suppose a study has two teaching methods and two class-size groups, with three test scores in each of the four cells:

Factor A Factor B Scores Cell mean
A1 B1 9, 10, 11 10
A1 B2 11, 12, 13 12
A2 B1 13, 14, 15 14
A2 B2 19, 20, 21 20

The grand mean is 14. The A-level means are 11 and 17; the B-level means are 12 and 16. Using the formulas above gives:

Source SS df MS F
Factor A 108 1 108 108
Factor B 48 1 48 48
A × B 12 1 12 12
Error 8 8 1
Total 176 11

For a balanced design, the degrees of freedom are:

  • A: (a-1)
  • B: (b-1)
  • Interaction: ((a-1)(b-1))
  • Error: (ab(n-1))
  • Total: (N-1)

Each mean square is (MS=SS/df). For example, (MS_E=8/8=1), so (F_A=108/1=108). The other F-statistics are (F_B=48) and (F_{AB}=12).

At a significance level of .05, each statistic is compared with an F distribution using the effect’s degrees of freedom and the error degrees of freedom. Here, each test uses (F(1,8)); its .05 critical value is about 5.32. All three statistics exceed that value. The interaction is statistically significant, so interpret the factor effects with care.

Important correction: The cell means and observations shown above produce SS values of 108, 48, 12, and 8. If you see different SS values claimed for these same data, check the arithmetic: the sums must add to the total SS of 176.

Assumptions, Model Choice, and Interpretation of Results

A two-way ANOVA’s p-values rely on a model that fits the study design and data reasonably well. In the standard fixed-effects model, errors are independent, approximately normal within cells, and have a common variance across cells. Check these conditions using the study design and residuals, not just a single pass-or-fail test.

Independence comes mainly from how data are collected. For example, repeated scores from the same person are not independent observations just because they appear in separate cells. A standard two-way ANOVA may not fit such a design; a repeated-measures or mixed model may be more suitable.

Check the data before interpreting the ANOVA table:

  • Confirm that the outcome is numeric and the factors are categorical.
  • Review cell counts, missing values, unusual observations, and cell means.
  • Use residual plots to look for changing spread or patterns.
  • Inspect a residual Q–Q plot for strong departures from normality.
  • Consider whether within-cell variances are reasonably similar.

These checks do not guarantee that every assumption is perfectly met. They help you spot issues that could affect the analysis. With unequal cell sizes, missing cells, or unequal variances, the appropriate model and sums-of-squares method may differ. Do not apply balanced-design formulas blindly; use software suited to the design and state the method used.

A significant interaction means the effect of A is not the same at every level of B, or vice versa. In the example, the cell means suggest that the gap between A1 and A2 differs between B1 and B2. Follow up with simple-effects tests or planned comparisons, and adjust for multiple comparisons when appropriate. Report the cell means so readers can see the pattern.

A significant main effect summarizes average differences across the other factor’s levels. If the interaction is significant, that summary may hide important differences. Avoid presenting a main effect as uniform when the interaction shows otherwise.

Reporting Findings and Applying Two-Way ANOVA to Research Questions

A useful report gives readers the design, descriptive results, test statistics, and practical context. Include the factor names and levels, the outcome, cell means, and whether the design was balanced or replicated. Report each effect’s F-statistic, degrees of freedom, p-value, and an effect size.

For example, partial eta squared is:

[ \eta_p^2=\frac{SS_{\text{effect}}}{SS_{\text{effect}}+SS_E} ]

For the example, partial (\eta^2) is (108/(108+8)=.93) for A, (48/(48+8)=.86) for B, and (12/(12+8)=.60) for the interaction. These values describe the share of effect-plus-error variation linked to each effect in this model. They are not proof of practical importance, and they should be read in context.

A compact result might say: “There was an interaction between teaching method and class-size group, (F(1,8)=12.00, p<.05, \eta_p^2=.60). Because the interaction was significant, we examined cell means and follow-up comparisons.” In formal work, report the exact p-value when available rather than only stating whether it crossed a threshold. Include confidence intervals for estimates where your analysis provides them.

For observational data, describe results as associations, not proof that a factor caused a change. A statistically significant result does not by itself show that an effect is large or useful. Pair the test with descriptive results and a clear account of how the data were collected.

Next step: Write down the research question in terms of the two factors and their interaction. Then verify the cell structure and assumptions before choosing the model.

Frequently Asked Questions

These brief answers clarify common points about two-way ANOVA, including what its variance terms mean, how replication affects the analysis, and what to do when an interaction is significant. Use them as a starting point, then check that the model matches your study’s design.

What does variance mean in two-way ANOVA?

Variance describes how spread out the outcome values are. ANOVA works with sums of squared differences, then divides them by degrees of freedom to get mean squares. It compares these mean squares to assess whether factor effects are large relative to within-cell error.

What is the interaction term?

The interaction term measures whether the effect of one factor changes across levels of the other factor. A significant interaction calls for examining cell means or simple effects rather than relying on either main effect alone.

How do I calculate the F-statistic?

For each effect, divide its mean square by the error mean square: (F=MS_{\text{effect}}/MS_E). Then use the F distribution with the effect’s degrees of freedom and the error degrees of freedom to find a p-value.

Can I run two-way ANOVA with one observation per cell?

Not for the standard model that estimates both interaction and error separately. With one observation per cell, these terms are confounded. Use another justified model or an external error estimate only when the study supports it.

What if the cell sizes are unequal?

Unequal cell sizes make the analysis less simple, and sums-of-squares choices can affect results. Use a method suited to the model and design, document the method, and do not assume the balanced-design formulas apply unchanged.

Do I still report main effects if the interaction is significant?

You can report them, but explain that they average across the other factor and may not describe each level well. Focus interpretation on the interaction pattern, cell means, and relevant follow-up tests.

What assumptions should I check?

Check whether observations are independent, residuals are reasonably normal within cells, and within-cell variances are reasonably similar. Also review outliers, missing cells, and the study design. Independence depends especially on how participants or units were sampled.

Does a significant result prove causation?

No. A significant ANOVA result shows evidence of differences or relationships under the model. Causal claims depend on the study design; an observational analysis alone does not establish that a factor caused the outcome.

(This article was written by one of our staff writers, Alan Westbrook. Visit our Meet the Team page.)

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *