I was under the expression that the mean square error (MS) of a 1-way anova table is the estimated variance, and that the between and within group variance add to the total variance. However, using an example I get an result which puts me into doubts. Here the example:
I have a dataset in matlab.
data = [1.5377 0.6923 1.6501 3.7950 5.6715
2.8339 1.5664 6.0349 3.8759 3.7925
-1.2588 2.3426 3.7254 5.4897 5.7172
1.8622 5.5784 2.9369 5.4090 6.6302
1.3188 4.7694 3.7147 5.4172 5.4889];
If I use the anova1 function I obtain the anova table
From this I expected that the variance of the columns is 13.4309 and the variance of the random error is 2.2204. I also expected to obtain that the two MS values add to the total variance. However, if I use the variance function, I get the result
var(data(:))
>> 4.0888
This result differens significantly from the MS sum.
I know that
- the sum-of-squares add up to the total sum-of-square (first column in picture) $$SS_{total} = SS_{columns} + SS_{error}$$
- that the total variance is given by $$var_{total} = SS_{total}/df_{total}$$
However, I often read the following: "we are divide the total variance into a bewteen and a within group variance". I expected that this is actually true. However, from the above example and the two pieces of knowledge I conclude that it's actually the total sum-of-squares, which is seperated and not the total variance. Is this true or is there a way to seperate the total variance into two groups?