Variance decomposition is the process of breaking down the total variance into between-group and within-group variances. Our goal is to determine if we can show a difference in the between-group signal given the within-group noise.
Because we have sample data, there will certainly be differences between the groups. Simply comparing the average value of the response variable for each group is not sufficient evidence of a difference between groups. What we want to know is if the differences we do observe between groups is evidence of a difference in the population for each group.
# total variance
The total variance, calculated as the total sum of squares (TSS) is the squared sum of the difference between each observation and the grand mean $\bar Y_{. \ .}$.
$TSS = \sum_{j=1}^J \sum_{i=1}^{n_j} (Y_{ij} - \bar Y_{. \ .})^2$
where the grand mean $\bar Y_{. \ .} = \frac{1}{J} \sum_{j=1}^J \bar Y_{. \ j}$ , the mean of the means for each group $J$.
# between group variability
The between group variance is the sum of squared differences between the means of each group and the grand mean.
$SS_{treat} = \sum_{j=1}^J (\bar Y_{. \ j} - \bar Y_{. \ .})^2$
# within group variability
The within group variance is the sum of squared differences between observations for a fixed group $j$.
$SS_{resid} = \sum_{i=1}^{n_j} (Y_{ij} - \bar Y_{. \ j})^2$
The total sum of squares is the sum of these two variances.
$TSS = SS_{treat} + SS_{resid}$