# Why compare sum of squares with ANOVA (and not mean)?

I got the following result of a ANOVA analysis of five independent variables with 5,8,2,2,6 levels and 5 replications for each combination:

                   Df Sum Sq Mean Sq F value Pr(>F)
IV1                 4 129805   32451  243.35 <2e-16 ***
IV2                 7  67227    9604   72.02 <2e-16 ***
IV3                 1  64253   64253  481.83 <2e-16 ***
IV4                 1 396445  396445 2972.94 <2e-16 ***
IV5                 5  91672   18334  137.49 <2e-16 ***
Residuals        4781 637553     133
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1


I now want to quantifiy which parameter has how much effect on the variation of the results. In a statistics book and suggest by an answer to my previous question I found the suggestion to simply calculate the ratio of the Sum of Square of the total Sum of Square. In my case as the Total sum of squares = 1386955 this would lead to 9% influence of the IV1 and 45% influence due to errors.

Question: Why is the Sum of Squares used here and not the mean of the sum of squares? The mean is calculated by dividing by the number of degrees of freedom. This seems much more logical to me: With more degrees of freedom, the sum of squares automatically gets higher so this must be compenstated somehow.

The results would be totaly different: IV1 would have 6% influence and the error would go down to below 1%.

Side question: Why is the Df for the residuals such a strange number? I thought the df of the residuals is a*b*c*d*...*(n-1), in my case 5*8*2*2*6*4=3840

-
Side answer: 4+7+1+1+5+4781 = 5*8*2*2*6*4. –  whuber Jul 13 '12 at 18:02
Just FYI, $SS(IV_j)/TSS$ is known as $\eta^2$ ("eta squared"). Another measure of effect size which is often preferred is partial eta squared $SS(IV_j)/(SSIV_j+SSE)$. These (& others) are very well discussed here. –  gung Aug 5 '12 at 13:47
@theomega, the residual df for an ANOVA is total df minus the df associated with your factors. Total df is $N-1$, and the df associated with your factors can be represented by $p=4+7+1+1+5=18$. Hence, the formula for residual df is $N-1-p$. From your output above, I assume your $N=4800$. –  gung Aug 5 '12 at 13:55

The ratio of the sum of square for a given term and the total sum of squares is an actual percentage since the sum of all the sum of squares terms (including residuals) will sum to the total sum of squares. Yes adding more degrees of freedom will increase the sum of squares (but it will also increase the total sum of squares).

The ratio of the mean squares is not a strict percentage. However there are functions of the ratios of mean squares that are then refered to as "adjusted $R^2$" values and have the advantage that you state in that when you add more degrees of freedom (add another variable) the $R^2$ value (or ratio of sums of squares) will increase (unless the new df is orthogonal to everything already in the model), but the adjusted $R^2$ will on average stay the same if the new term(s) don't add to the model. The adjusted $R^2$ can sometimes be negative which is a bit harder to interpret.

-

The mean squares in an ANOVA are all independent estimates of the population variance. The mean square for factor A (AKA independent variable A) is an estimate of the population variance calculated based on the Ka means for the levels of variable A. Likewise, the mean square for factor B is an estimate of the population variance calculated based on the Kb means for factor B. The estimates of the population variance are based on this relationship: the variance of a mean is equal to the population variance divided by N (where N is the size of the groups that each mean is based on). In ANOVA, we work this formula backward for each effect to get an estimate of the population variance based on an effect. For example, since you know (i.e., calculate from the data) the variance based on the Ka means for Factor A, all from groups of size N, you can multiple this (observed) variance of the Ka means by N (the group size) to get an estimate of the population variance. You do this separately for each main effect and interaction. These estimates can NOT be used to get the percent of variance due to factor A or factor B. (Note that the mean squares for the effects do NOT sum to the mean square total.) For the contribution of each factor to the overall variance, you need to look at the sum of squares for each effect, which do sum to the total mean square.

-
This is wrong. What population variance does it represent? –  Michael Chernick Jul 14 '12 at 0:14
The mean squares are independent estimates of the population variance. The population variance being estimated is that for the whole population. Under the null hypothesis that there are no mean score differences due to treatments, these several variance estimates should be equal (or not significantly different). For example, if your estimate of the population variance based on the Ka factor A means is greater than your estimate of the population variance based on within group calculations, this difference can be evaluated by the F ratio. The F ratio is a ratio of two variance estimates. –  Joel W. Jul 15 '12 at 23:49