How to compute the sum of squares in one way ANOVA: method 1

Sum of squares computed as sum of squared deviations
Example data:
SubjectScoreGroup
1231
2251
3181
4292
5192
6212
7353
8173


Group mean 1 = $(23 + 25 + 18) / 3 = 22$
Group mean 2 = $(29 + 19 + 21) / 3 = 23$
Group mean 3 = $(35 + 17) / 2 = 26$

Grand mean = $(23 + 25 + 18 + 29 + 19 + 21 + 35 + 17) / 8 = 23.375$
Sum of squares within (SSW):
  1. For each subject, compute the difference between its score and its group mean. You thus have to compute each of the group means, and compute the difference between each of the scores and the group mean to which that score belongs
  2. Square all these differences
  3. Sum the squared differences
SSW example data = $(23 - 22)^2 + (25 - 22)^2 + (18 - 22)^2 + (29 - 23)^2 + (19 - 23)^2 + (21 - 23)^2 + (35 - 26)^2 + (17 - 26)^2 = 244$

Sum of squares between (SSB):
  1. For each subject, compute the difference between its group mean and the grand mean. The grand mean is the mean of all $N$ scores (just sum all scores and divide by the total sample size $N$)
  2. Square all these differences
  3. Sum the squared differences
SSB example data = $(22 - 23.375)^2 + (22 - 23.375)^2 + (22 - 23.375)^2 + (23 - 23.375)^2 + (23 - 23.375)^2 + (23 - 23.375)^2 + (26 - 23.375)^2 + (26 - 23.375)^2 = 19.875$

Sum of squares total (SST):
  1. For each subject, compute the difference between its score and the grand mean
  2. Square all these differences
  3. Sum the squared differences
SST example data = $(23 - 23.375)^2 + (25 - 23.375)^2 + (18 - 23.375)^2 + (29 - 23.375)^2 + (19 - 23.375)^2 + (21 - 23.375)^2 + (35 - 23.375)^2 + (17 - 23.375)^2 = 263.875$

If you have computed two of the three sums of squares, you can easily computed the third one by using the fact that SST = SSW + SSB.


How to compute the sum of squares in one way ANOVA: method 2

Sum of squares computed as differences between sums of squares
Example data:
SubjectScoreGroup
1231
2251
3181
4292
5192
6212
7353
8173


Group mean 1 = $(23 + 25 + 18) / 3 = 22$
Group mean 2 = $(29 + 19 + 21) / 3 = 23$
Group mean 3 = $(35 + 17) / 2 = 26$

Grand mean = $(23 + 25 + 18 + 29 + 19 + 21 + 35 + 17) / 8 = 23.375$
First, compute [Y], [A], and [T]:
[Y] =
  1. Square each score
  2. Sum all the squared scores
[Y] example data = $23^2 + 25^2 + 18^2 + 29^2 + 19^2 + 21^2 + 35^2 + 17^2 = 4635$

[A] =
  1. Square each group mean
  2. Multiply each squared group mean by the number of subjects in that group
  3. Sum all these products
[A] example data = $3\times22^2 + 3\times23^2 + 2\times26^2 = 4391$

[T] =
  1. Square the grand mean
  2. Multiply the squared grand mean by the total sample size
[T] example data = $8\times23.375^2 = 4371.125$

Sum of squares within (SSW) = [Y] - [A]
SSW example data = 4635 - 4391 = 244

Sum of squares between (SSB) = [A] - [T]
SSB example data = 4391 - 4371.125 = 19.875

Sum of squares total (SST) = [Y] - [T]
SST example data = 4635 - 4371.125 = 263.875

If you have computed two of the three sums of squares, you can easily computed the third one by using the fact that SST = SSW + SSB.