Squared deviations from the mean (SDM) result from squaring deviations. In probability theory and statistics, the definition of variance is either the expected value of the SDM (when considering a theoretical distribution) or its average value (for actual experimental data). Computations for analysis of variance involve the partitioning of a sum of SDM.
An understanding of the computations involved is greatly enhanced by a study of the statistical value
\operatorname{E}(X2)
\operatorname{E}
X
\mu
\sigma2
\sigma2=\operatorname{E}(X2)-\mu2.
(Its derivation is shown here.) Therefore,
\operatorname{E}(X2)=\sigma2+\mu2.
From the above, the following can be derived:
\operatorname{E}\left(\sum\left(X2\right)\right)=n\sigma2+n\mu2,
\operatorname{E}\left(\left(\sumX\right)2\right)=n\sigma2+n2\mu2.
The sum of squared deviations needed to calculate sample variance (before deciding whether to divide by n or n - 1) is most easily calculated as
S=\sumx2-
\left(\sumx\right)2 | |
n |
From the two derived expectations above the expected value of this sum is
\operatorname{E}(S)=n\sigma2+n\mu2-
n\sigma2+n2\mu2 | |
n |
which implies
\operatorname{E}(S)=(n-1)\sigma2.
This effectively proves the use of the divisor n - 1 in the calculation of an unbiased sample estimate of σ2.
See main article: Partition of sums of squares.
In the situation where data is available for k different treatment groups having size ni where i varies from 1 to k, then it is assumed that the expected mean of each group is
\operatorname{E}(\mui)=\mu+Ti
and the variance of each treatment group is unchanged from the population variance
\sigma2
Under the Null Hypothesis that the treatments have no effect, then each of the
Ti
It is now possible to calculate three sums of squares:
I=\sumx2
\operatorname{E}(I)=n\sigma2+n\mu2
T=
k | |
\sum | |
i=1 |
\left(\left(\sum
2/n | |
x\right) | |
i\right) |
\operatorname{E}(T)=k\sigma2+
k | |
\sum | |
i=1 |
ni(\mu+
2 | |
T | |
i) |
\operatorname{E}(T)=k\sigma2+n\mu2+2\mu
k | |
\sum | |
i=1 |
(niTi)+
k | |
\sum | |
i=1 |
ni(T
2 | |
i) |
Under the null hypothesis that the treatments cause no differences and all the
Ti
\operatorname{E}(T)=k\sigma2+n\mu2.
C=\left(\sumx\right)2/n
\operatorname{E}(C)=\sigma2+n\mu2
Under the null hypothesis, the difference of any pair of I, T, and C does not contain any dependency on
\mu
\sigma2
\operatorname{E}(I-C)=(n-1)\sigma2
\operatorname{E}(T-C)=(k-1)\sigma2
\operatorname{E}(I-T)=(n-k)\sigma2
The constants (n - 1), (k - 1), and (n - k) are normally referred to as the number of degrees of freedom.
In a very simple example, 5 observations arise from two treatments. The first treatment gives three values 1, 2, and 3, and the second treatment gives two values 4, and 6.
I=
12 | |
1 |
+
22 | |
1 |
+
32 | |
1 |
+
42 | |
1 |
+
62 | |
1 |
=66
T=
(1+2+3)2 | |
3 |
+
(4+6)2 | |
2 |
=12+50=62
C=
(1+2+3+4+6)2 | |
5 |
=256/5=51.2
Giving
Total squared deviations = 66 - 51.2 = 14.8 with 4 degrees of freedom.
Treatment squared deviations = 62 - 51.2 = 10.8 with 1 degree of freedom.
Residual squared deviations = 66 - 62 = 4 with 3 degrees of freedom.