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

Contents

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

Note that theoretically, it is always possible to 'downgrade' the measurement level of a variable. For instance, a test that can be performed on a variable of ordinal measurement level can also be performed on a variable of interval measurement level, in which case the interval variable is downgraded to an ordinal variable. However, downgrading the measurement level of variables is generally a bad idea since it means you are throwing away important information in your data (an exception is the downgrade from ratio to interval level, which is generally irrelevant in data analysis).

If you are not sure which method you should use, you might like the assistance of our method selection tool or our method selection table.

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:
Assumptions

Statistical tests always make assumptions about the sampling procedure that was used to obtain the sample data. So called parametric tests also make assumptions about how data are distributed in the population. Non-parametric tests are more 'robust' and make no or less strict assumptions about population distributions, but are generally less powerful. Violation of assumptions may render the outcome of statistical tests useless, although violation of some assumptions (e.g. independence assumptions) are generally more problematic than violation of other assumptions (e.g. normality assumptions in combination with large samples).

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.
Significant?

This is how you find out if your test result is significant:

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?
SPSS

How to perform a two way ANOVA in SPSS:

Analyze > General Linear Model > Univariate...
Jamovi

How to perform a two way ANOVA in jamovi:

ANOVA > ANOVA