Degrees of freedom
In the diagram below, each arrow corresponds to adding a term to the model. The sums of squares explained by adding the term has degrees of freedom equal to its number of non-zero parameters.
Neither X nor Z affects Y yijk = µ + εijk |
||||
![]() |
![]() |
|||
Only X affects Y yijk = µ + βi + εijk |
Only Z affects Y yijk = µ + γj + εijk |
|||
![]() |
![]() |
|||
X and Z affect Y with no interaction yijk = µ + βi + γj + εijk |
||||
![]() |
||||
X and Z affect Y with interaction yijk = µ + βi + γj + δij + εijk |
If factor X has gX levels and factor Z has gZ levels, then the different terms have degrees of freedom given in the table below.
Non-zero parameters (degrees of freedom) |
|
---|---|
Constant term, µ | 1 |
Main effect for X, β | (gX - 1) |
Main effect for Z, γ | (gZ - 1) |
Interaction terms, δ | (gX - 1)(gZ - 1) |
Total | gXgZ |
Note that the total number of non-zero parameters equals the number of treatments (i.e. the number of combinations of factor levels).
Analysis of variance table
As in most other models for experiments, the significance of terms is tested using an analysis of variance table with rows giving the explained sums of squares for a sequence of terms that are added to the model.
As in other applications of analysis of variance, the explained sums of squares are divided by their degrees of freedom to give mean sums of squares. These are then divided by the mean residual sum of squares to give F ratios. A p-value associated with each F ratio tests whether the corresponding term is needed in the model. (The p-values are found from F distributions.)
Source of variation |
Sum of sqrs |
d.f. | Mean ssq | F-ratio | p-value |
---|---|---|---|---|---|
X | SSX | (gX - 1) | MSX | MSX / MSResid | (F distn) |
Z | SSZ | (gZ - 1) | MSZ | MSZ / MSResid | (F distn) |
Interaction | SSXZ | (gX - 1)(gZ - 1) | MSXZ | MSXZ / MSResid | (F distn) |
Residual | SSResid | n - gXgZ | MSResid | ||
Total | SSTotal | n - 1 |
(Note again that we are restricting attention in this section to experiments with the same number of replicates for each combination of factor levels and hence orthogonal factors. The order of adding X and Z therefore does not affect their sums of squares and the first two rows of the anova table could be swapped.)
In particular, the F ratio for the interaction term is found from the interaction sum of squares. A small F ratio could have arisen by chance, so the p-value for testing is the probability of such an F ratio as high if there was no underlying interaction (the null hypothesis of the test).
Interpretation of p-values
The p-value associated with the interaction term is interpreted in a similar way to that for other hypothesis tests.
p-value | Interpretation |
---|---|
over 0.1 | no evidence of interaction |
between 0.05 and 0.1 | very weak evidence of interaction |
between 0.01 and 0.05 | moderately strong evidence of interaction |
under 0.01 | strong evidence of interaction |
Order of testing
The analysis of variance table also includes F ratios and associated p-values for the main effects of X and Z. These p-values should not be used unless it is concluded that there is no interaction.
If there is an interaction, it is not meaningful to test the main effects for X and Z.
It would make no sense to drop the main effect terms from the model if there is evidence from the interaction p-value that X and Z interact in their effect on the response!
Bait Acceptability by Feral Pigs
Drag the red arrow in the analysis of variance table to successively add main effects for Gender and Feed type and then an interaction between these variables. Each successive term reduces the residual sum of squares. Note that the experimental design is balanced (2 replicates for each combination of factor levels) so the main effects could have been added in the opposite order with the same sums of squares.
The p-value corresponding to the interaction sum of squares is large (0.3023) so we should come to the following conclusion about the interaction:
There is no evidence that male and female pigs would react differently to changes to the feeds.
Drag up the arrow to remove the interaction from the model. Since the main effect for gender has p-value 0.0747, there is also little evidence of a main effect for Gender, so we can further conclude that
There is little evidence of any difference between the change in intake (Day 2 minus Day 1) for male and female pigs getting the same diet.