logo

Two-way ANOVA 📂Statistical Test

Two-way ANOVA

Hypothesis Testing 1

Suppose there are kk treatments and bb blocks in an experimental design, from which n=bkn = bk samples are obtained. Assume that the samples of the j=1,,kj = 1 , \cdots , kth treatment are independently and randomly distributed following a normal distribution N(μj,σj2)N \left( \mu_{j} , \sigma_{j}^{2} \right), with the population variance of each normal distribution being equal, i.e., σ2=σ12==σk2\sigma^{2} = \sigma_{1}^{2} = \cdots = \sigma_{k}^{2}. In the two-way ANOVA for comparing population means across groups, the hypothesis test is as follows:

  • H0H_{0}: μ1==μk\mu_{1} = \cdots = \mu_{k}
  • H1H_{1}: At least one μj\mu_{j} is different from the others.

Test Statistic

Assume the ANOVA table is provided under a randomized block design.

SourcedfSSMSF
Treatmentsk1k-1SSTMSTMST/MSE
Blocksb1b-1SSBMSB
Error(k1)(b1)(k-1)(b-1)SSEMSE
Totaln1n-1TSS

The test statistic is given by: F=MSTMSE=SST/(k1)SSE/(k1)(b1) F = {\frac{ \text{MST} }{ \text{MSE} }} = {\frac{ \text{SST} / (k - 1) }{ \text{SSE} / (k - 1)(b - 1) }} This test statistic follows an F-distribution F(k1,(k1)(b1))F \left( k - 1 , (k - 1)(b - 1) \right) with (k1),(k1)(b1)(k-1), (k - 1)(b - 1) degrees of freedom under the assumption that the null hypothesis is true.

Explanation

Let the mean for each treatment be denoted as xˉj:=ixij/nj\bar{x}_{j} := \sum_{i} x_{ij} / n_{j}, and the overall mean as xˉ:=ijxij/n\bar{x} := \sum_{ij} x_{ij} / n. SST=j=1knj(xˉjxˉ)2SSE=(n11)s12++(nk1)sk2SSB=i=1b(xixˉ)2MST=SSTk1MSB=SSBb1MSE=SSE(b1)(k1)F=MSTMSE=SST/(k1)SSE/(b1)(k1)=SSTSSE/(b1) \begin{align*} \text{SST} =& \sum_{j=1}^{k} n_{j} \left( \bar{x}_{j} - \bar{x} \right)^{2} \\ \text{SSE} =& \left( n_{1} - 1 \right) s_{1}^{2} + \cdots + \left( n_{k} - 1 \right) s_{k}^{2} \\ \text{SSB} =& \sum_{i=1}^{b} \left( x_{i} - \bar{x} \right)^{2} \\ \text{MST} =& {\frac{ \text{SST} }{ k - 1 }} \\ \text{MSB} =& {\frac{ \text{SSB} }{ b - 1 }} \\ \text{MSE} =& {\frac{ \text{SSE} }{ (b-1)(k-1) }} \\ F =& {\frac{ \text{MST} }{ \text{MSE} }} = {\frac{ \text{SST}/ (k - 1) }{ \text{SSE} / (b-1)(k-1) }} = {\frac{ \text{SST}}{ \text{SSE} / (b-1) }} \end{align*} For the derivation of the test statistic, refer to F-test in ANOVA.

Precautions

One cautionary note is that although a block is added in a two-way ANOVA, the primary focus remains on the differences between treatments, hence MSB\text{MSB} should not be a concern2. It is evident from the test statistic FF that it only incorporates SST\text{SST}, which, when compared with the test statistic of one-way ANOVA, differs only in the numerator. Although there is a possibility for a test for differences between blocks, denoted by FBF_{B}, the main focus should first be on differences between treatments. FB=MSBMSE=SSB/(b1)SSE/(b1)(k1)=SSBSSE/(k1) F_{B} = {\frac{ \text{MSB} }{ \text{MSE} }} = {\frac{ \text{SSB} / (b - 1) }{ \text{SSE} / (b-1)(k-1) }} = {\frac{ \text{SSB}}{ \text{SSE} / (k-1) }} Analogously to the original FF, this test statistic follows an F-distribution F(b1,(b1)(k1))F \left( b - 1 , (b - 1)(k - 1) \right) with (b1),(b1)(k1)(b-1), (b-1)(k-1) degrees of freedom under the assumption that the null hypothesis is true.

Example 3

A university seeks to determine if gas usage differs by season: spring, fall, and winter, in its laboratories. Since each lab might have different characteristics or preferences, they decided to use four similar labs A, B, C, and D as blocks to mitigate any discrepancies among them. Using data on seasonal gas usage from these labs, let’s perform an analysis under a randomized block design. The null hypothesis is that the mean gas usage is identical for each season, while the alternative hypothesis is that at least one season has a different mean gas usage.

LabSpringFallWinter
A2768308
B2476326
C3165312
D2367300

The overall mean is 135.6, with seasonal means being 26.3 for spring, 69.0 for fall, and 311.5 for winter.

Given the number of treatments k=3k = 3 and blocks b=4b = 4, SST=189,335.2\text{SST} = 189,335.2 and SSE=241.5\text{SSE} = 241.5 allow FF to be computed as follows: F=SST/SSE/(b1)=189,335.2/2241.5/3=2352.0 F = {\frac{ \text{SST} / }{ \text{SSE} /(b - 1) }} = {\frac{ 189,335.2 / 2 }{ 241.5 / 3 }} = 2352.0 Considering (k1)=2(k-1) = 2 and (k1)(b1)=6(k-1)(b-1) = 6, at a significance level α=5%\alpha = 5\%, the lower bound of the rejection region is F2,6(0.05)=5.14F_{2, 6} (0.05) = 5.14, and F5.14F \gg 5.14, thereby allowing the null hypothesis to be rejected. In other words, at least one season’s mean gas usage differs from another.

However, as previously mentioned, it’s unnecessary to strictly test differences according to blocks, but the test statistic for blocks will be FB=1.84F_{B} = 1.84, which is smaller than F3,6(0.05)=4.76F_{3, 6} (0.05) = 4.76, indicating the null hypothesis cannot be rejected. Therefore, gas usage does not significantly differ by lab.

Verification

alt text

See Also

Experimental DesignParametric MethodsNon-Parametric Methods
Completely Randomized DesignOne-Way ANOVAKruskal-Wallis HH Test
Randomized Block DesignTwo-Way ANOVAFriedman FrF_{r} Test

  1. Mendenhall. (2012). Introduction to Probability and Statistics (13th Edition): p471. ↩︎

  2. 경북대학교 통계학과. (2008). 엑셀을 이용한 통계학: p291. ↩︎

  3. Mendenhall. (2012). Introduction to Probability and Statistics (13th Edition): p469. ↩︎