I'm trying to get an intuitive understanding of why the sum of squares between groups needs to be multiplied by the number of observations within each group. Using the iris
dataset in R
as an example, the sum of squares needs to be multiplied by 50:
meanOverall = mean(iris$Sepal.Length)
meanSetosa = mean(iris$Sepal.Length[iris$Species=='setosa'])
meanVersicolor = mean(iris$Sepal.Length[iris$Species=='versicolor'])
meanVirginica = mean(iris$Sepal.Length[iris$Species=='virginica'])
sumsquaresBetweenGroups = sum((meanSetosa - meanOverall) * (meanSetosa - meanOverall) + (meanVersicolor - meanOverall) * (meanVersicolor - meanOverall) +
(meanVirginica - meanOverall) * (meanVirginica - meanOverall)) * 50
Why do you need to multiply the between groups sum of squares by the number of observations in each group?
In addition, what if $n$ is different in each group. What would you do if there were 45, 55 and 60 observations in each of the three groups of Species
in the iris
dataset?