Two way ANOVA

This page offers all the basic information you need about two way ANOVA. It is part of Statkat’s wiki module, containing similarly structured info pages for many different statistical methods. The info pages give information about null and alternative hypotheses, assumptions, test statistics and confidence intervals, how to find p values, SPSS how-to’s and more.

To compare two way ANOVA with other statistical methods, go to Statkat's or practice with two way ANOVA at Statkat's


When to use?

Deciding which statistical method to use to analyze your data can be a challenging task. Whether a statistical method is appropriate for your data is partly determined by the measurement level of your variables. Two way ANOVA requires the following variable types:

Variable types required for two way ANOVA :
Independent/grouping variables:
Two categorical, the first with $I$ independent groups and the second with $J$ independent groups ($I \geqslant 2$, $J \geqslant 2$)
Dependent variable:
One quantitative of interval or ratio level



Null hypothesis

Two way ANOVA tests the following null hypothesis (H0):

ANOVA $F$ tests: Like in one way ANOVA, we can also perform $t$ tests for specific contrasts and multiple comparisons. This is more advanced stuff.
Alternative hypothesis

Two way ANOVA tests the above null hypothesis against the following alternative hypothesis (H1 or Ha):

ANOVA $F$ tests:


Two way ANOVA makes the following assumptions:

Test statistic

Two way ANOVA is based on the following test statistic:

For main and interaction effects together (model): For independent variable A: For independent variable B: For the interaction term: Note: mean square error is also known as mean square residual or mean square within.
Pooled standard deviation

$ \begin{aligned} s_p &= \sqrt{\dfrac{\sum\nolimits_{subjects} (\mbox{subject's score} - \mbox{its group mean})^2}{N - (I \times J)}}\\ &= \sqrt{\dfrac{\mbox{sum of squares error}}{\mbox{degrees of freedom error}}}\\ &= \sqrt{\mbox{mean square error}} \end{aligned} $
Sampling distribution

Sampling distribution of $F$ if H0 were true:

For main and interaction effects together (model): For independent variable A: For independent variable B: For the interaction term: Here $N$ is the total sample size.


Effect size

ANOVA table

This is how the entries of the ANOVA table are computed:

two way ANOVA table
Equivalent to

Two way ANOVA is equivalent to:

OLS regression with two categorical independent variables and the interaction term, transformed into $(I - 1)$ + $(J - 1)$ + $(I - 1) \times (J - 1)$ code variables.
Example context

Two way ANOVA could for instance be used to answer the question:

Is the average mental health score different between people from a low, moderate, and high economic class? And is the average mental health score different between men and women? And is there an interaction effect between economic class and gender?

How to perform a two way ANOVA in SPSS:

Analyze > General Linear Model > Univariate...

How to perform a two way ANOVA in jamovi: