Let's say we have two factors (A and B), each with two levels (A1, A2 and B1, B2) and a response variable (y).

The when performing a two way ANOVA of the type:


We are testing three null hypothesis:

  1. There is no difference in the means of factor A
  2. There is no difference in means of factor B
  3. There is no interaction between factors A and B

When written down, the first two hypothesis are easy to formulate (for 1 it is $H_0:\; \mu_{A1}=\mu_{A2}$)

But how should hypothesis 3 be formulated?

edit: and how would it be formulated for the case of more then two levels?


  • 3
    $\begingroup$ I don't have the reputation to allow me to edit, but I think you want $H_0 = \mu_{A1}=\mu_{A2}$ (or $\mu_{A_1}$ if you want a double subscript) [oops, it has automatically tex-ified that: H_0 = \mu_{A1}=\mu_{A2} or \mu_{A_1}] $\endgroup$
    – Ben Bolker
    Commented Dec 18, 2010 at 15:12
  • 1
    $\begingroup$ Oups, didn't see that you are using capital letters to denote factor name and their levels -- fix it (following @Ben notation). $\endgroup$
    – chl
    Commented Dec 18, 2010 at 16:12

2 Answers 2


I think it's important to clearly separate the hypothesis and its corresponding test. For the following, I assume a balanced, between-subjects CRF-$pq$ design (equal cell sizes, Kirk's notation: Completely Randomized Factorial design).

$Y_{ijk}$ is observation $i$ in treatment $j$ of factor $A$ and treatment $k$ of factor $B$ with $1 \leq i \leq n$, $1 \leq j \leq p$ and $1 \leq k \leq q$. The model is $Y_{ijk} = \mu_{jk} + \epsilon_{i(jk)}, \quad \epsilon_{i(jk)} \sim N(0, \sigma_{\epsilon}^2)$

Design: $\begin{array}{r|ccccc|l} ~ & B 1 & \ldots & B k & \ldots & B q & ~\\\hline A 1 & \mu_{11} & \ldots & \mu_{1k} & \ldots & \mu_{1q} & \mu_{1.}\\ \ldots & \ldots & \ldots & \ldots & \ldots & \ldots & \ldots\\ A j & \mu_{j1} & \ldots & \mu_{jk} & \ldots & \mu_{jq} & \mu_{j.}\\ \ldots & \ldots & \ldots & \ldots & \ldots & \ldots & \ldots\\ A p & \mu_{p1} & \ldots & \mu_{pk} & \ldots & \mu_{pq} & \mu_{p.}\\\hline ~ & \mu_{.1} & \ldots & \mu_{.k} & \ldots & \mu_{.q} & \mu \end{array}$

$\mu_{jk}$ is the expected value in cell $jk$, $\epsilon_{i(jk)}$ is the error associated with the measurement of person $i$ in that cell. The $()$ notation indicates that the indices $jk$ are fixed for any given person $i$ because that person is observed in only one condition. A few definitions for the effects:

$\mu_{j.} = \frac{1}{q} \sum_{k=1}^{q} \mu_{jk}$ (average expected value for treatment $j$ of factor $A$)

$\mu_{.k} = \frac{1}{p} \sum_{j=1}^{p} \mu_{jk}$ (average expected value for treatment $k$ of factor $B$)

$\alpha_{j} = \mu_{j.} - \mu$ (effect of treatment $j$ of factor $A$, $\sum_{j=1}^{p} \alpha_{j} = 0$)

$\beta_{k} = \mu_{.k} - \mu$ (effect of treatment $k$ of factor $B$, $\sum_{k=1}^{q} \beta_{k} = 0$)

$(\alpha \beta)_{jk} = \mu_{jk} - (\mu + \alpha_{j} + \beta_{k}) = \mu_{jk} - \mu_{j.} - \mu_{.k} + \mu$
(interaction effect for the combination of treatment $j$ of factor $A$ with treatment $k$ of factor $B$, $\sum_{j=1}^{p} (\alpha \beta)_{jk} = 0 \, \wedge \, \sum_{k=1}^{q} (\alpha \beta)_{jk} = 0)$

$\alpha_{j}^{(k)} = \mu_{jk} - \mu_{.k}$
(conditional main effect for treatment $j$ of factor $A$ within fixed treatment $k$ of factor $B$, $\sum_{j=1}^{p} \alpha_{j}^{(k)} = 0 \, \wedge \, \frac{1}{q} \sum_{k=1}^{q} \alpha_{j}^{(k)} = \alpha_{j} \quad \forall \, j, k)$

$\beta_{k}^{(j)} = \mu_{jk} - \mu_{j.}$
(conditional main effect for treatment $k$ of factor $B$ within fixed treatment $j$ of factor $A$, $\sum_{k=1}^{q} \beta_{k}^{(j)} = 0 \, \wedge \, \frac{1}{p} \sum_{j=1}^{p} \beta_{k}^{(j)} = \beta_{k} \quad \forall \, j, k)$

With these definitions, the model can also be written as: $Y_{ijk} = \mu + \alpha_{j} + \beta_{k} + (\alpha \beta)_{jk} + \epsilon_{i(jk)}$

This allows us to express the null hypothesis of no interaction in several equivalent ways:

  1. $H_{0_{I}}: \sum_{j}\sum_{k} (\alpha \beta)^{2}_{jk} = 0$
    (all individual interaction terms are $0$, such that $\mu_{jk} = \mu + \alpha_{j} + \beta_{k} \, \forall j, k$. This means that treatment effects of both factors - as defined above - are additive everywhere.)

  2. $H_{0_{I}}: \alpha_{j}^{(k)} - \alpha_{j}^{(k')} = 0 \quad \forall \, j \, \wedge \, \forall \, k, k' \quad (k \neq k')$
    (all conditional main effects for any treatment $j$ of factor $A$ are the same, and therefore equal $\alpha_{j}$. This is essentially Dason's answer.)

  3. $H_{0_{I}}: \beta_{k}^{(j)} - \beta_{k}^{(j')} = 0 \quad \forall \, j, j' \, \wedge \, \forall \, k \quad (j \neq j')$
    (all conditional main effects for any treatment $k$ of factor $B$ are the same, and therefore equal $\beta_{k}$.)

  4. $H_{0_{I}}$: In a diagramm which shows the expected values $\mu_{jk}$ with the levels of factor $A$ on the $x$-axis and the levels of factor $B$ drawn as separate lines, the $q$ different lines are parallel.

  • 1
    $\begingroup$ A really impressive answer Caracal - thank you. $\endgroup$
    – Tal Galili
    Commented Dec 19, 2010 at 22:05

An interaction tells us that the levels of factor A have different effects based on what level of factor B you're applying. So we can test this through a linear contrast. Let C = (A1B1 - A1B2) - (A2B1 - A2B2) where A1B1 stands for the mean of the group that received A1 and B1 and so on. So here we're looking at A1B1 - A1B2 which is the effect that factor B is having when we're applying A1. If there is no interaction this should be the same as the effect B is having when we apply A2: A2B1 - A2B2. If those are the same then their difference should be 0 so we could use the tests:

$H_0: C = 0\quad\text{vs.}\quad H_A: C \neq 0.$

  • 1
    $\begingroup$ Thanks Dason, that helped. Also, after reading your reply, it suddenly became clear to me that I am not fully sure how this generalizes in case we are having more factors. Could you advise? Thanks again. Tal $\endgroup$
    – Tal Galili
    Commented Dec 18, 2010 at 14:21
  • 2
    $\begingroup$ You can test multiple contrasts simultaneously. So for example if A had three levels and B had 2 we could use the two contrasts: C1 = (A1B1 - A2B1) - (A2B1 - A2B2) and C2 = (A2B1 - A2B2) - (A3B1 - A3B2) and use a 2 degree of freedom test to simultaneously test if C1 = C2 = 0. It's also interesting to note that C2 could equally have been (A1B1 - A1B2) - (A3B1 - A3B2) and we would come up with the same thing. $\endgroup$
    – Dason
    Commented Dec 18, 2010 at 14:23
  • $\begingroup$ Hi @Dason: you seem to have multiple accounts. Could you please complete the form at stats.stackexchange.com/contact and request that they be merged? That will simplify your use of this site (and give you the combined net reputation of both accounts). $\endgroup$
    – whuber
    Commented Sep 25, 2013 at 19:23

Not the answer you're looking for? Browse other questions tagged or ask your own question.