## Degrees of Freedom For a Factorial ANOVA

### 2001-04-15

A categorical independent variable is called a factor. The categories are called the levels of the factor.

Replications are experiment observations made under the same conditions, that is, under the same combination of factor levels.

An experimental design is said to be balanced if each combination of factor levels is replicated the same number of times.

For the main effect of a factor, the degrees of freedom is the number of levels of the factor minus 1. To understand this intuitively, note that if there are I levels, there are I - 1 comparisons between the levels.

For an interaction between factors, the degrees of freedom is the product of the degrees of freedom for the corresponding main effects. To understand this intuitively, note that if there are two factors, with I levels of the first factor and J levels of the second factor, there are I - 1 comparisons of the levels of the first factor at each of the J - 1 comparisons of the levels of the second factor.

For error, think of the error mean square as a pooled s2. If there were 2 replications at each combination of the 2 factors, you would have s2 on 2-1 degrees of freedom at each combination. Hence, pooling over all factor combinations,

error df = (2-1)*(number of combinations).

If there were 3 replications

error df = (3-1)*(number of combinations).

Then you should find that all the degrees of freedom add up to the total which is the total number of observations minus 1.

Consider a balanced 2-factor design. Suppose there are I levels of the first factor and J levels of the second factor, and K replications at each of the IJ combinations of the two factors. Then there are IJK observations and

(IJK - 1) = (I - 1) + (J - 1) + (I -1)(J - 1) + IJ(K - 1)

is the breakdown of the total degrees of freedom into: main effect of the first factor, main effect of the second factor, interaction between the two factors, and error.

For example, suppose you have Factor A at 4 levels, Factor B at 3 levels, and 3 replications of every combination of Factor A and Factor B. Then I = 4, J = 3, K = 3 and there are 36 observations. The SV and DF columns of the ANOVA will be:

```   SV           DF
Factor A         3
Factor B         2
Interaction AxB  6
Error           24

Total           35```