# Interesting derivation of R squared

Years ago I found this identity through experimentation playing with data and transformations. After explaining it to my statistics professor he came in the next class with a one-page proof using vector and matrix notation. Unfortunately I lost the paper he gave me. (This was back in 2007)

Is anyone able to reconstruct a proof?

Let $(x_i,y_i)$ be your original data points. Define a new set of data points by rotating the original set by angle $\theta$; call these points $(x'_i,y'_i)$.

The R squared value of the original set of points is equal to the negative product of the derivative with respect to $\theta$ of the natural log of the standard deviation for each coordinate of the new set of points, each evaluated at $\theta=0$

$r^2= - \left(\left.\frac{d}{d\theta}\ln(\sigma_{x'})\right|_{\theta=0} \right) \left(\left.\frac{d}{d\theta}\ln(\sigma_{y'})\right|_{\theta=0} \right)$

Derivation is not particularly interesting exercise of symbolic manipulation. Since, \begin{align} \left.\frac{dx'}{d\theta}\right|_{\theta=0}&=-y,\\ \left.\frac{dy'}{d\theta}\right|_{\theta=0}&=x, \end{align} and $s_x^2=\frac{1}{n}\sum_{i=1}^{n}(x_i-\bar{x})^2$ $$\left.\frac{ds_{x'}^2}{d\theta}\right|_{\theta=0}=-2s_{xy}$$ $$\left.\frac{ds_{y'}^2}{d\theta}\right|_{\theta=0}=2s_{xy}$$
$$\left.\frac{d}{d\theta}\ln(s_{x'})\right|_{\theta=0} = -\frac{s_{xy}}{s_x^2},\quad \left.\frac{d}{d\theta}\ln(s_{y'})\right|_{\theta=0} = \frac{s_{xy}}{s_y^2}$$ and the result follows.