Statistics – How Does $\sum (Y_i-\bar{Y})^2 = \sum Y_i^2 – n\bar{Y}^2$?

arithmeticstatisticssummation

I've tried my algebra backwards and forwards and starting from the left-hand side of the equation below I just can't get to the right-hand side. I'm always left with an extra term $-2Y_i\bar{Y}$.

$\sum (Y_i-\bar{Y})^2 = \sum Y_i^2 – n\bar{Y}^2$

Best Answer

$$\begin{align*}\sum (Y_i-\bar{Y})^2 &= \sum (Y_i^2-2\bar{Y}Y_i+\bar{Y}^2)\\&= \sum Y_i^2-2\bar{Y}\underbrace{\sum Y_i}_{=\bar{Y}\cdot n} +\underbrace{\sum\bar{Y}^2}_{=n\times\bar{Y}^2}\\\\&= \sum Y_i^2-2\bar{Y}\bar{Y}\cdot n+ n\cdot \bar{Y}^2 \\&=\sum Y_i^2-n\bar{Y}^2\end{align*}$$