# Thread: correlation and r square

1. ## correlation and r square

Hi all

I have two questions relating to correlation:

Firstly where does the first 'n' in the numerator come from in the far right hand expression of the equation below

Secondly, I am trying to work out the derivation of correlation^2 = r^2. I have started with squaring the above expression and trying to simplify, but I don't feel like I'm going about it the right way. Could someone give me a shove in the right direction please?

2. Originally Posted by factfinder
Hi all

I have two questions relating to correlation:

Firstly where does the first 'n' in the numerator come from in the far right hand expression of the equation below

Secondly, I am trying to work out the derivation of correlation^2 = r^2. I have started with squaring the above expression and trying to simplify, but I don't feel like I'm going about it the right way. Could someone give me a shove in the right direction please?
$\sum_{i=1}^n \left(X_i - \overline{X}\right) \left(Y_i - \overline{Y}\right) = \sum_{i=1}^n \left( X_i Y_i - \overline{Y} X_i - \overline{X} Y_i + \overline{X} ~ \overline{Y}\right)$

$= \sum_{i=1}^n X_i Y_i - \overline{Y} \sum_{i=1}^n X_i - \overline{X} \sum_{i=1}^n Y_i + \sum_{i=1}^n \overline{X} ~ \overline{Y}$

$= \sum_{i=1}^n X_i Y_i - \overline{Y} (n \overline{X}) - \overline{X} (n \overline{Y}) + n \overline{X} ~ \overline{Y}$

$= \sum_{i=1}^n X_i Y_i - n \overline{X} ~ \overline{Y}$.

3. Hi Mr Fantastic

sorry I was looking for how to get from this:

$
\frac{\sum x_i y_i - n \overline{x} ~ \overline{y}}{(n-1) s_x s_y}
$

to this:

$
\frac{n \sum x_i y_i - \sum x_i \sum y_i}{\sqrt{n \sum x_i^2 - (\sum x_i)^2}\sqrt{n \sum y_i^2 - (\sum y_i)^2}}
$

(with the first equation I have the same thing in a textbook but completely omitting the (n-1) term in the denominator, so I'm not sure how that is so for starters...)

4. Originally Posted by factfinder
Hi Mr Fantastic

sorry I was looking for how to get from this:

$
\frac{\sum x_i y_i - n \overline{x} ~ \overline{y}}{(n-1) s_x s_y}
$

to this:

$
\frac{n \sum x_i y_i - \sum x_i \sum y_i}{\sqrt{n \sum x_i^2 - (\sum x_i)^2}\sqrt{n \sum y_i^2 - (\sum y_i)^2}}
$

(with the first equation I have the same thing in a textbook but completely omitting the (n-1) term in the denominator, so I'm not sure how that is so for starters...)
$n \overline{x} ~ \overline{y} = n \, \frac{\sum x_i}{n} \, \frac{\sum y_i}{n} = \frac{\sum x_i ~ \sum y_i}{n}$

so multiply the numerator and denominator by $n$.

5. Thanks Mr Fantastic.

Am I right in saying that the (n-1) term in the original denominator is discarded then?

6. Originally Posted by factfinder
Thanks Mr Fantastic.

Am I right in saying that the (n-1) term in the original denominator is discarded then?
No. The formulae for $s_x$ and $s_y$ have been substituted and simplification done.