Deriving $R^2$ from $R$

101 Views Asked by At

I got stuck on a seemingly very simple problem while revising my notes on linear regression. More specifically with deriving $R^2$ from $R$.

Wikipedia page for Pearson correlation coefficient starts the derivation of $R^2$ as such:

$$ R = \frac{\sum (y-\bar{y})(\hat{y}-\bar{y})} {\sqrt{\sum (y-\bar{y})^{2}\cdot \sum (\hat{y}-\bar{y})^{2}}} = \ldots = \sqrt{\frac{\sum (\hat{y}-\bar{y})^{2}}{\sum (y-\bar{y})^{2}}} $$

And this is where I got stuck. If I take both sides (left and right of $=\ldots=$) of the above equation, square them and simplify a bit, I get this:

$$ \begin{split} \frac{\sum (y-\bar{y})(\hat{y}-\bar{y})} {\sqrt{\sum (y-\bar{y})^{2}\cdot \sum (\hat{y}-\bar{y})^{2}}} &=\sqrt{\frac{\sum (\hat{y}-\bar{y})^{2}}{\sum (y-\bar{y})^{2}}} \\ \frac{(\sum (y-\bar{y})(\hat{y}-\bar{y}))^{2}} {\sum (y-\bar{y})^{2}\cdot \sum (\hat{y}-\bar{y})^{2}} &=\frac{\sum (\hat{y}-\bar{y})^{2}}{\sum (y-\bar{y})^{2}} \\ \frac{(\sum (y-\bar{y})(\hat{y}-\bar{y}))^{2}} {\sum (\hat{y}-\bar{y})^{2}} &=\sum (\hat{y}-\bar{y})^{2} \\ (\sum (y-\bar{y})(\hat{y}-\bar{y}))^2 &= (\sum (\hat{y}-\bar{y})^{2})^{2} \\ \sum (y-\bar{y})(\hat{y}-\bar{y}) &= \sum (\hat{y}-\bar{y})(\hat{y}-\bar{y}) \end{split} $$

Doesn't this imply that $y=\hat{y}$? Makes no sense. Can you spot the mistake?

Thanks Edvin