How to use the residual mean square from an ANOVA table to quantify uncertainty and compare treatment means.
Below is an example of a 2-way Analysis of Variance (ANOVA) for a randomised complete block design. From the ANOVA table, we’re going to see how to calculate:
- The standard error of a mean (SEM).
- The confidence interval (CI) for a mean.
- The standard error of the difference between two means (SED).
- The least significant difference between two means (LSD).
- The confidence interval for the difference between two means.
Source of variation d.f. s.s. m.s. v.r. F pr.
block stratum 2 0.30850 0.15425 3.44
block.*Units* stratum
Nitrogen 2 4.59223 2.29611 51.22 <.001
Sulphur 3 0.97720 0.32573 7.27 0.001
Nitrogen.Sulphur 6 0.64851 0.10808 2.41 0.061
Residual 22 0.98625 0.04483
Total 35 7.51269
The ANOVA table gives us an estimate of the residual mean square (s2) – also known as the mean square error, residual error or residual variation. This is the variation in the data unexplained by the ANOVA model. In the example above, this is the variation remaining after the block effects (block) and treatment effects (Nitrogen, Sulphur and the Nitrogen by Sulphur interaction, Nitrogen.Sulphur) have been accounted for.
The standard error of a mean (SEM) is calculated using the following formula:
where n is the number of replicates (or sample size).
The SEM describes the uncertainty in our estimate of the population mean for a treatment from the available data. The bigger the sample size (i.e., the larger n), the smaller the SEM and the more precise our estimate is.
In our example, there are 12 unique treatment combinations: the 3 levels of Nitrogen by the 4 levels of Sulphur. Note, we can obtain the number of levels of each treatment, and number of blocks, from the degrees of freedom in the ANOVA table.
Source of d.f. variation block stratum 2 ← Number of blocks − 1 block.*Units* stratum Nitrogen 2 ← Number of levels of Nitrogen − 1 Sulphur 3 ← Number of levels of Sulphur − 1 Nitrogen.Sulphur 6 ← (Number of levels of Nitrogen − 1) × (Number of levels of Sulphur − 1) Residual 22 Total 35
Furthermore, the total number of degrees of freedom + 1 gives us the number of experimental units. Thus, in our example, there are 36 experimental units, with each of the 12 unique treatment combinations occurring exactly once in each of the 3 blocks.
Therefore…
- The 12 Nitrogen by Sulphur means have replication of 3 (1 replicate per block).
For example, the 3 replicates of the treatment corresponding to the first level of Nitrogen and the second level of Sulphur (Nitrogen 1 Sulphur 2) are highlighted yellow in the schematic below of our randomised complete block design:
| Plot | Block 1 | Block 2 | Block 3 |
|---|---|---|---|
| 1 | Nitrogen 3 Sulphur 4 | Nitrogen 1 Sulphur 2 | Nitrogen 3 Sulphur 1 |
| 2 | Nitrogen 2 Sulphur 2 | Nitrogen 2 Sulphur 1 | Nitrogen 2 Sulphur 2 |
| 3 | Nitrogen 1 Sulphur 4 | Nitrogen 3 Sulphur 1 | Nitrogen 2 Sulphur 1 |
| 4 | Nitrogen 2 Sulphur 4 | Nitrogen 3 Sulphur 3 | Nitrogen 2 Sulphur 3 |
| 5 | Nitrogen 2 Sulphur 1 | Nitrogen 1 Sulphur 4 | Nitrogen 1 Sulphur 2 |
| 6 | Nitrogen 1 Sulphur 3 | Nitrogen 2 Sulphur 2 | Nitrogen 1 Sulphur 1 |
| 7 | Nitrogen 3 Sulphur 2 | Nitrogen 1 Sulphur 1 | Nitrogen 2 Sulphur 4 |
| 8 | Nitrogen 1 Sulphur 1 | Nitrogen 3 Sulphur 4 | Nitrogen 1 Sulphur 3 |
| 9 | Nitrogen 2 Sulphur 3 | Nitrogen 2 Sulphur 3 | Nitrogen 3 Sulphur 4 |
| 10 | Nitrogen 1 Sulphur 2 | Nitrogen 2 Sulphur 4 | Nitrogen 3 Sulphur 3 |
| 11 | Nitrogen 3 Sulphur 3 | Nitrogen 3 Sulphur 2 | Nitrogen 1 Sulphur 4 |
| 12 | Nitrogen 3 Sulphur 1 | Nitrogen 1 Sulphur 3 | Nitrogen 3 Sulphur 2 |
Thus, the standard error for the Nitrogen by Sulphur means is:
- The 3 Nitrogen means, pooled over the four Sulphur levels, have replication of 12 (3 blocks x 4 levels of Sulphur).
For example, the replicates of the first level of Nitrogen (Nitrogen 1) are highlighted in yellow:
| Plot | Block 1 | Block 2 | Block 3 |
|---|---|---|---|
| 1 | Nitrogen 3 Sulphur 4 | Nitrogen 1 Sulphur 2 | Nitrogen 3 Sulphur 1 |
| 2 | Nitrogen 2 Sulphur 2 | Nitrogen 2 Sulphur 1 | Nitrogen 2 Sulphur 2 |
| 3 | Nitrogen 1 Sulphur 4 | Nitrogen 3 Sulphur 1 | Nitrogen 2 Sulphur 1 |
| 4 | Nitrogen 2 Sulphur 4 | Nitrogen 3 Sulphur 3 | Nitrogen 2 Sulphur 3 |
| 5 | Nitrogen 2 Sulphur 1 | Nitrogen 1 Sulphur 4 | Nitrogen 1 Sulphur 2 |
| 6 | Nitrogen 1 Sulphur 3 | Nitrogen 2 Sulphur 2 | Nitrogen 1 Sulphur 1 |
| 7 | Nitrogen 3 Sulphur 2 | Nitrogen 1 Sulphur 1 | Nitrogen 2 Sulphur 4 |
| 8 | Nitrogen 1 Sulphur 1 | Nitrogen 3 Sulphur 4 | Nitrogen 1 Sulphur 3 |
| 9 | Nitrogen 2 Sulphur 3 | Nitrogen 2 Sulphur 3 | Nitrogen 3 Sulphur 4 |
| 10 | Nitrogen 1 Sulphur 2 | Nitrogen 2 Sulphur 4 | Nitrogen 3 Sulphur 3 |
| 11 | Nitrogen 3 Sulphur 3 | Nitrogen 3 Sulphur 2 | Nitrogen 1 Sulphur 4 |
| 12 | Nitrogen 3 Sulphur 1 | Nitrogen 1 Sulphur 3 | Nitrogen 3 Sulphur 2 |
(Note, within each of the 3 blocks, a given level of Nitrogen corresponds to 4 unique treatment combinations: 1 at each level of Sulphur).
Thus, the standard error for the Nitrogen means is:
- The 4 Sulphur means, pooled over the 3 Nitrogen levels, have replication of 9 (3 blocks x 3 levels of Nitrogen).
For example, the replicates of the second level of Sulphur (Sulphur 2) are highlighted yellow:
| Plot | Block 1 | Block 2 | Block 3 |
|---|---|---|---|
| 1 | Nitrogen 3 Sulphur 4 | Nitrogen 1 Sulphur 2 | Nitrogen 3 Sulphur 1 |
| 2 | Nitrogen 2 Sulphur 2 | Nitrogen 2 Sulphur 1 | Nitrogen 2 Sulphur 2 |
| 3 | Nitrogen 1 Sulphur 4 | Nitrogen 3 Sulphur 1 | Nitrogen 2 Sulphur 1 |
| 4 | Nitrogen 2 Sulphur 4 | Nitrogen 3 Sulphur 3 | Nitrogen 2 Sulphur 3 |
| 5 | Nitrogen 2 Sulphur 1 | Nitrogen 1 Sulphur 4 | Nitrogen 1 Sulphur 2 |
| 6 | Nitrogen 1 Sulphur 3 | Nitrogen 2 Sulphur 2 | Nitrogen 1 Sulphur 1 |
| 7 | Nitrogen 3 Sulphur 2 | Nitrogen 1 Sulphur 1 | Nitrogen 2 Sulphur 4 |
| 8 | Nitrogen 1 Sulphur 1 | Nitrogen 3 Sulphur 4 | Nitrogen 1 Sulphur 3 |
| 9 | Nitrogen 2 Sulphur 3 | Nitrogen 2 Sulphur 3 | Nitrogen 3 Sulphur 4 |
| 10 | Nitrogen 1 Sulphur 2 | Nitrogen 2 Sulphur 4 | Nitrogen 3 Sulphur 3 |
| 11 | Nitrogen 3 Sulphur 3 | Nitrogen 3 Sulphur 2 | Nitrogen 1 Sulphur 4 |
| 12 | Nitrogen 3 Sulphur 1 | Nitrogen 1 Sulphur 3 | Nitrogen 3 Sulphur 2 |
Thus, the standard error for the Sulphur means is:
The confidence interval (CI) for a mean is
where tα/2,rdf is the α/2 critical value of the t distribution with rdf degrees of freedom. For a confidence interval of C%, α = 1 − C/100. For example, for a 95% confidence interval, α = 0.05. The rdf refers to the residual degrees of freedom. This can be read directly from the ANOVA table.
Source of variation d.f. s.s. m.s. v.r. F pr.
block stratum 2 0.30850 0.15425 3.44
block.*Units* stratum
Nitrogen 2 4.59223 2.29611 51.22 <.001
Sulphur 3 0.97720 0.32573 7.27 0.001
Nitrogen.Sulphur 6 0.64851 0.10808 2.41 0.061
Residual 22 0.98625 0.04483
Total 35 7.51269
In a nutshell, a C% confidence interval for a mean is a range of values that you can be C% certain contains the true population mean. Although, strictly speaking, the confidence level C% represents a long-run percentage: the C% confidence interval gives an estimated range of values that we would expect the true, but unknown, population parameter to lie within C% of the times, should we repeat our experiment a large number of times.
The tables of means for our example are given below:
Grand mean 1.104
Nitrogen 1 2 3
0.601 1.313 1.398
Sulphur 1 2 3 4
0.829 1.155 1.167 1.266
Nitrogen.Sulphur 1 2 3 4
1 0.560 0.770 0.524 0.552
2 0.894 1.289 1.525 1.545
3 1.032 1.404 1.454 1.700
For example, the 95% confidence interval for the overall mean for Sulphur level 4 is:
Similarly, the 99% confidence interval for the Nitrogen level 1, Sulphur level 3 mean is:
The standard error of the difference between two means (SED) is calculated using the following formula:
Note: The formula is different when the sample sizes of the means being compared are unequal.
The SED describes the uncertainty in our estimate of the difference between two population means.
For our example, the SED between …
a) two Nitrogen by Sulphur means is:
b) two overall Nitrogen means is:
and
c) two overall Sulphur means is:
Two means can be compared using their least significant difference (LSD). The LSD gives the smallest value in which the absolute difference between the two means is deemed to be is statistically significant at the α level of significance. The LSD is given by:
Thus, for our example, the LSD(5%) for comparing …
a) two Nitrogen by Sulphur means is:
b) two overall Nitrogen means is:
and
c) two overall Sulphur means is:
Using the overall means for Nitrogen as an example, at the 5% significance level…
- there is statistical evidence that the Nitrogen 1 and Nitrogen 2 means differ
- there is statistical evidence that the Nitrogen 1 and Nitrogen 3 means differ
- there is NO statistical evidence that the Nitrogen 2 and Nitrogen 3 means differ
The difference between two means can also be compared, and more fully described, using a confidence interval for the difference between two means. This is given by:
or, equivalently,
where m1 and m2 are the two means being compared.
Once again. using the overall means for Nitrogen as an example, the 95% confidence interval for the difference between:
- the Nitrogen 1 and Nitrogen 2 means is:
- the Nitrogen 1 and Nitrogen 3 means is:
- the Nitrogen 2 and Nitrogen 3 means
Notice that the CIs comparing Nitrogen 1 with Nitrogen 2, and Nitrogen 1 with Nitrogen 3, both exclude zero. Hence, we can conclude, at the 5% significance level, that the mean for Nitrogen 1 is significant differently from both the Nitrogen 2 and Nitrogen 3 means. (In this case the mean for Nitrogen 1 is lower than that of Nitrogen 2 and Nitrogen 3). Conversely, as the CI comparing Nitrogen 2 and Nitrogen 3 includes zero, we conclude that there is no evidence of a difference between these two means (at the 5% significance level).
Luckily for us, we rarely need to calculate these quantities ourselves, as they are generated by most statistical software packages. However, it is useful to understand how they are calculated and how they are related. For example, in order to scrutinize reported results, or to calculate, at a later date, a quantity that you’ve forgotten to generate.

Genstat has a very powerful set of ANOVA tools, that are straightforward and easy to use. In addition to the ANOVA table, you can readily output the treatment means, SEMs, SEDs, LSDs and CIs.