Skip to content

Method | Analysis of Variance

Posted on:October 21, 2023

Summary

TypeRegression FormulaYXM
One-way ANOVAY ~ Xscalardiscrete/
Two-way ANOVA (× replication)Y ~ X + Mscalardiscretediscrete
Two-way ANOVA (√ replication)Y ~ X + M + X * Mscalardiscretediscrete
ANCOVAY ~ X + M + X * Mscalardiscretecontinuous
MANOVAY ~ Xvectordiscrete/

Table of contents

1. One-way ANOVA

Y ~ X

1.1 Experiment design

In a location that has never grown wheat before, wheat cultivation begins with selecting varieties (品种) through field experiments. There are kk varieties and nn experimental fields - each variety occupies nin_i fields, which allows for the estimation of random errors.

Once the number of fields for each variety is determined, the fields are allocated using a randomization (随机化) method - This prevents the case that a variety is assigned to a particularly fertile field, leading to higher yields unrelated to the variety’s qualities.

The objective is to compare the yield differences among the various wheat varieties and identify the most suitable variety for cultivation in the region. Here,

1.2 Model specification

Let YijY_{ij} denote the j-th observation of the i-th level:

Our model:

Yij=ai+eij(i=1k, j=1ni)Y_{ij} = a_i + e_{ij} \quad (i=1 \sim k,\ j=1 \sim n_i)

Our question / null hypothesis:

a1=a2==aka_1=a_2=\cdots=a_k

Assumptions:

1.3 Theoretical analysis

Why YijY_{ij} vary?

Total variation (Y_bar = average across all individuals):

SS=i=1kj=1ni(YijYˉ)2SS = \sum_{i=1}^k \sum_{j=1}^{n_i}(Y_{ij}-\bar{Y})^2

Variation due to random error (i.e. 组内变异):

SSE=i=1kj=1ni(YijYˉi)2SSE = \sum_{i=1}^k \sum_{j=1}^{n_i}(Y_{ij}-\bar{Y}_i)^2

Variation due to different level (i.e. 组间变异):

SSA=SSSSE=i=1kni(YˉiYˉ)2SSA = SS - SSE = \sum_{i=1}^k n_i(\bar{Y}_i-\bar{Y})^2

1.4 Full test: a1=a2=…=ak?

When the proportion of SSA in the SS is higher, it is easier to reject our previously stated H0. Therefore, the test statistic we choose is:

SSASSE\frac{SSA}{SSE}

When the random error term follow a normal distribution and H0 is true, it follows that:

SSA/(k1)SSE/(nk)Fk1,nk\frac{SSA/(k-1)}{SSE/(n-k)} \sim F_{k-1,n-k}

Set the test level at 1α1-\alpha. Accept H0 when:

MSAMSEFk1,nk(α)\frac{MSA}{MSE} \le F_{k-1,n-k}(\alpha)

, otherwise reject H0. Note, if the test result is significant (reject H0), then there is reason to believe that a1~ak are not all the same — but this does not necessarily mean that none of them are the same.

1.5 Partial test: a_u=a_v?

We can test whether au=ava_u=a_v by calculating the confidence interval (CI) for auava_u - a_v.

Yˉu=au+eˉuN(au,σ2nu)Yˉv=av+eˉvN(av,σ2nv)\bar{Y}_u = a_u + \bar{e}_u \sim N(a_u,\frac{\sigma^2}{n_u}) \\ \bar{Y}_v = a_v + \bar{e}_v \sim N(a_v,\frac{\sigma^2}{n_v})

Hence, the point estimate of auava_u-a_v, YˉuYˉv\bar{Y}_u - \bar{Y}_v, follows:

N(auav,(1nu+1nv)σ2)N(a_u-a_v, (\frac{1}{n_u}+\frac{1}{n_v})\sigma^2)

Then we have:

(YˉuYˉv)(auav)1nu+1nv×σN(0,1)\frac{(\bar{Y}_u-\bar{Y}_v)-(a_u-a_v)}{\sqrt{\frac{1}{n_u}+\frac{1}{n_v}}×\sigma} \sim N(0,1)

MSE is an unbiased estimate of σ2\sigma^2. Substitute σ^\hat{\sigma} for σ\sigma:

(YˉuYˉv)(auav)1nu+1nv×σ^t(nk)\frac{(\bar{Y}_u-\bar{Y}_v)-(a_u-a_v)}{\sqrt{\frac{1}{n_u}+\frac{1}{n_v}}×\hat{\sigma}} \sim t(n-k)

We can construct a CI for auava_u-a_v with a confidence coefficient of 1α1-\alpha. If 0 is not within this CI, then it indicates that there is indeed a significant difference between aua_u and ava_v.

[Warning! Inflation of type I error] For just a single pair aua_u and ava_v, the probability that the CI contains the parameter is 1α1-\alpha. However, when constructing confidence intervals for multiple pairs, the probability that all intervals include their parameters decreases to (1α)m(1-\alpha)^m. For example, if α=0.05\alpha=0.05 and m=10m=10, the probability that all 10 intervals contain their parameters is only 0.95100.600.95^{10} \approx 0.60. Therefore, for pairwise comparisons, alternative methods such as the Tukey–Cramer Method should be considered, instead of direct pair comparisons.

1.6 Connection with regression

Single-factor (k levels) ANOVA is equivalent to a linear regression with one categorical variable that can take k values. Thus, it can be transformed into k-1 dummy variables included in the linear regression model.

2. Two-way ANOVA

2.1 Without replication

Y ~ X + M

two-way-anova-without

In this case, we have two factors: factor A has k1k_1 levels and factor B has k2k_2 levels. The total number of unique combinations of these factors is k1×k2k_1 × k_2. Unlike the previous setting where multiple experiments (nin_i) are conducted for each level of a single factor, here we conduct only one experiment for each combination of Factor A and Factor B levels.

Our model:

Yij=μ+ai+bj+eij(i=1k1, j=1k2)Y_{ij} = \mu + a_i + b_j + e_{ij} \quad (i=1 \sim k_1,\ j=1 \sim k_2)

Our null hypotheses:

H0A:a1=a2==ak1=0H0B:b1=b2==bk2=0H_{0A}: a_1 = a_2 = \cdots = a_{k_1} = 0\\ H_{0B}: b_1 = b_2 = \cdots = b_{k_2} = 0

Variance decomposition:

SS=SSA+SSB+SSESS=i=1k1j=1k2(YijYˉ)2SSA=i=1k1k2(YˉiYˉ)2SSB=j=1k2k1(YˉjYˉ)2SS = SSA + SSB + SSE \\ SS = \sum_{i=1}^{k_1} \sum_{j=1}^{k_2}(Y_{ij}-\bar{Y})^2\\ SSA = \sum_{i=1}^{k_1} k_2 (\bar{Y}_{i*}-\bar{Y})^2\\ SSB = \sum_{j=1}^{k_2} k_1 (\bar{Y}_{*j}-\bar{Y})^2\\

Total variation is caused by variation among levels in factor A, variation among levels in factor B, and random error. The test statistics are similar to those in the single-factor setting: the larger the MSA/MSEMSA/MSE, the more probable it is to reject the null hypothesis H0AH_{0A} that factor A does not have a significant impact on DV.

Why we do two-way ANOVA without replication? Introducing a new factor (i.e. independent variable) can further decompose the SS, resulting in a smaller SSE; thus, group differences that were not detectable in one-way ANOVA might be detected here.

2.2 With replication

Y ~ X + M + X*M

two-way-anova-with

Besides reducing SSE, a two-way ANOVA with replication is mainly used to detect interaction effects between two factors:

two-way-anova-with2

3. ANCOVA

Y ~ X + M + X*M (M is a continuous variable)

One-way ANOVA is used to evaluate whether significant differences exist among the outcomes of various treatments (i.e different levels within a factor). Two-way ANOVA combines two factors within a single study to examine not only the main effects of each factor but also how they interact with each other. To sum up, ANOVA serves as a statistical approach where the predictors are discrete variables (categorical or ordinal). What if we have both discrete and continuous predictors? In such cases, we use ANCOVA.

We can understand the motivation for ANCOVA from two perspectives. First, it can be seen as an improved version of the two-way ANOVA with replication, suitable for a continuous predictor. Thus, its motivation is the same as that of the two-way ANOVA with replication. Second, as indicated by its name, incorporating covariates, or control variables, allows for the exclusion of certain confounding factors.

For more details, please refer to ANCOVA (Analysis of Covariance) in SPSS.

4. MANOVA

ANOVA only has one DV, whereas in MANOVA, there are multiple dependent variables. One possible scenario is that performing MANOVA reveals significant differences between groups, but when conducting separate ANOVAs for each dependent variable, no significant differences are found among the groups:

manova

ANOVA (individual j in group i):

YijN(ai,σ2)Y_{ij} \sim N(a_i, \sigma^2)

MANOVA:

YijN(ai,Σ)\vec{Y}_{ij} \sim N(\vec{a}_i, \Sigma)

MANOVA requires checking the homogeneity of the covariance matrices: While ANOVA assumes that the variances of the error terms are the same across all groups, in MANOVA this assumption extends to the covariance matrices. Box’s M test can be used to verify this.

Reference