Calculating the degrees of freedom

Hi I wonder if there is a standard way to calculate the degrees of freedom. I am having a hard time understanding why these sums of squares has only one degree of freedom.

1. In one-way ANOVA (one factor of $$a$$ levels), the sum of squares for a contrast $$\sum_{i=1}^ac_i\tau_i$$ for $$\sum_{i=1}^ac_i = 0$$ has one degree of freedom. $$SS_C = \frac{\left(\sum_{i=1}^ac_i\bar{y}_{i\cdot}\right)^2}{\frac{1}{n}\sum_{i=1}^ac_i^2}$$

2. In two-way ANOVA (factor A of $$a$$ levels and factor B of $$b$$ levels) and the model is $$y_{ij} = \mu + \tau_i + \beta_j + \epsilon_{ij}$$, $$i = 1, 2, ..., a$$, $$j=1, 2, ..., b$$. Suppose that there is only a single replicate and we assume $$(\tau\beta)_{ij} = \gamma\tau_i\beta_j$$ for a constant $$\gamma$$. The Tukey test for significance of interaction says that the following $$SS_N = \frac{\left[\sum_{i=1}^a\sum_{j=1}^by_{ij}y_{i\cdot}y_{\cdot j} - y_{\cdot\cdot}\left(SS_A + SS_B + \frac{y_{\cdot\cdot}^2}{ab}\right)\right]^2}{abSS_ASS_B}$$ has one degree of freedom. There is a paper talking about this test.

I am very confused about these cases and I wonder if there is any standard way that we can calculate the degrees of freedom.

Thank you very much for your help!

Every time you write the "equals" sign =, you spend one degree of freedom (unless you can derive this equal sign from others supplied before).

You wrote down one contrast (+1, -1, 0, 0)? That's one degree of freedom.

You wrote down two contrasts (+1, -1, 0, 0) and (-0.5, 0, -0.5, +1)? That's two degrees of freedom.

You wrote down three contrasts (+1, -1, 0, 0), (+1, 0, -1, 0) and (0, +1, -1, 0)? Well you can deduce the third one by subtracting the first one from the second one:

$$\begin{pmatrix}+1 \\ 0 \\ -1 \\ 0 \end{pmatrix} - \begin{pmatrix} +1 \\ -1 \\ 0 \\ 0 \end{pmatrix} = \begin{pmatrix} 0 \\ +1 \\ -1 \\ 0 \end{pmatrix}$$

So there are only two equalities you are testing, so that's two degrees of freedom.

You wrote down that you think $$\gamma = 0$$? That's one degree of freedom.

• This is incorrect because it ignores the possibility of linear dependence among the equations.
– whuber
Commented Feb 23, 2021 at 18:31
• You are right, @whuber -- I added a paragraph in the middle to that effect. Commented Feb 23, 2021 at 19:31
• Thank you very much for your answer. I wonder why the two sums of squares have 1 degree of freedom. I am still not so clear what you mean by the equal sign, do you mean it is the "equal to zero"? Could you please recommend some source about this as well?
– wut
Commented Feb 24, 2021 at 4:46
• C R Rao's LSI is a classic amazon.com/Linear-Statistical-Inference-its-Applications/dp/… Commented Mar 3, 2021 at 13:21
• @StasK for $SS_E$ of one-way anova for example, with your explanation, why does it have $n-p$ degrees of freedom?
– wut
Commented Mar 9, 2021 at 4:47

I think I have found the answer here. The degrees of freedom are "the rank of a quadratic form".