Mean of squared "sum of squared errors" Let $X_i, i=1,\dots,n$ are independent with mean $\mu$ and variance $\sigma^2$.
For example they are iid normal distributed.
I wonder how to calculuate
$
\mathrm{E} \{[\sum_i (X_i - \bar{X})^2]^2\}
$
?
My first try:
$$
\mathrm{E} \{[\sum_i (X_i - \bar{X})^2]^2\}
= \mathrm{Var} \{[\sum_i (X_i - \bar{X})^2]^2\} + [\mathrm{E} \sum_i (X_i - \bar{X})^2]^2
$$
I know  $
\mathrm{E} [\sum_i (X_i - \bar{X})^2] = (n-1) \sigma^2.
$
So I am tempted to find $\mathrm{Var} \{[\sum_i (X_i - \bar{X})^2]^2\}$, which seems to me harder than the original problem.
My second try:
$$
\mathrm{E} [\sum_i (X_i - \bar{X})^2]^2\
= \mathrm{E} \{\sum_i [X_i^2 - 2 X_i \bar{X} + \bar{X}^2]\}^2
= \mathrm{E} [\sum_i (X_i^2) - n \bar{X}^2]^2
$$
Unsure how to proceed.
Thanks.
 A: This is known as a moment of moment problem ... it is often convenient to express such problems in power sum notation namely:   $s_r = \sum_{i=1}^n X_i^r$. For your problem, express:
$$p = \sum_{i=1}^n (X_i - \bar{X})^2  = s_2 - \frac{s_1^2}{n}$$
Then, you seek $E[p^2]$, which is simply the $1^{st}$ RawMoment of $p^2$:

where:


*

*RawMomentToCentral is a function from the mathStatica package for Mathematica, and 

*$\mu_i$ denotes the $i^{th}$ central moment of the population of $X$. 


Note that the solution obtained is completely general and valid for any distribution whose moments exist ... not just for the Normal case. 
For the Normal case: 
For you specific case, i.e. with a $N(\mu, \sigma^2)$ parent, $\mu_2 = \sigma^2$ and $\mu_4 = 3 \sigma^4$, so the general solution simplifies to:
$$\sigma^4 (n^2 - 1)$$
Notes


*

*As disclosure, I should add that I am one of the authors of the software used above.

*Jonas asks (comments below):  "What is the theorem that the software is based on?"
The theorem is known as the fundamental expectation result, which expresses the expectation of an augmented symmetric function in terms of moments of the parent population. For more detail, see Stuart and Ord (1994, Section (12.5)), or see Chapter 7 of our Springer book: Rose and Smith (2002, section 7.4) ... a free download of which is available here:
http://www.mathstatica.com/book/bookcontents.html
It is possible to do such calculations by hand ... but it rapidly gets extremely tedious, and such problems are far more easily solved with computer. In fact, we found a number of errors in the tables in Stuart and Ord using the software, as well as errors in solutions derived by Fisher (the famous one).
