# One way ANOVA vs Two way ANOVA

Today in class we talked about Two-way ANOVA, so my question is how to understand the essence of these two kinds of ANOVA? I’ll try to spend less than one hour to write down what I thought about it.

Let’s take a look at an example, we have treatments $i \in \{1,2,\dots,I\}$ and groups $j\in \{1,2,\dots,J\}$ and for each treatment $i$ and group $j$, we have $m_{i,j}$ samples, so our two-way ANOVA model should would be

$\mu_{ijk}=\mu_{ij}+\epsilon_{ij;k}$ where $\mu_{ij}$ is the mean of the $i$th treatment and $j$th group.

What if we want to use one-way ANOVA to model it? What would that be look like? Because there may be interaction between the treatment and group, so in my understanding, we should consider this model be a linear model with respect to three terms, i.e. treatment level , group level  and interaction level , so the model should be $X_{ijk}=\mu_0+\alpha_{i} +\beta_{j} +\gamma_{ij} +\epsilon_{ijk}$, now we consider the least square solution for $\mu_0,\alpha_i,\beta_j,\gamma_{ij}$ we have

$\min_{\mu_0,\alpha_i,\beta_j,\gamma_{ij}} S=\sum_{i,j,k} (X_{ijk}-\mu_0-\alpha_i-\beta_j-\gamma_{ij})^2$

By taking derivatives with respect to $\mu_0,\alpha,\beta,\gamma$, we have

$\mu_0 \sum_{ij} m_{ij}=\sum_{ijk} X_{ijk}-\sum_{i}\alpha_i(\sum_j m_{ij})-\sum_{j}\beta_j(\sum_{i} m_{ij})-\sum_{i,j} \gamma_{ij} m_{ij}$

$\alpha_i\sum_j m_{ij}=\sum_{jk} X_{ijk}-\mu_0\sum_j m_{ij}-\beta_i\sum_j m_{ij}-\sum_j(\gamma_{ij} m_{ij})$

$\beta_j\sum_j m_{ij}=\sum_{ik} X_{ijk}-\mu_0\sum_i m_{ij}-\alpha_j\sum_i m_{ij}-\sum_i(\gamma_{ij} m_{ij})$

$\gamma_{ij}=\frac{1}{m_{ij}}\sum_k X_{ijk}-\mu_0 -\alpha_i-\beta_j$

Then the solution of these equations is the two-way ANONA estimator.

So as we can see that if there is only one factor, there would not exist the interaction term $\gamma$, then we can just regard the original linear model be $I$ different group and analyse individually.

So in sum, so called “Two-way ANOVA” is mainly dealing with the interaction between two different “factors”. So question is if there are three different factors, can we follow the same idea do the “many-factors ANOVA”?