Correlation

Recall , and our alternative formula , which says that: \Cov(X, Y) = \E\left[(X - \E(X))(Y - \E(Y))\right] \E\left(XY\right) - \E(X)\E(Y). One observation we made about the covariance is that, if X and Y tend to get bigger (than their respective averages) and smaller (than their respective averages) together, then \Cov(X, Y) will be positive. If one variable tends to get big while the other gets small, \Cov(X, Y) will be negative.

However, it's not clear how to interpret the magnitude of \Cov(X, Y). One thought that we might investigagte is to compare \Cov(X, Y) to \Cov(10X, 10Y) (or some other scaling factor). In principal, if we want to measure the tendency of X and Y to get big or small simultaneously, it would be nice if our measure wasn't simply confused by the scale of the values themselves.

\Cov(10X, 10Y) \amp = \E(10X \cdot 10Y) - \E(10X)\E(10Y) \amp = 100 \E(XY) - 100 \E(X)\E(Y) \amp = 100 \left(\E(XY) - \E(X)\E(Y)\right) \amp = 100 \Cov(X, Y). So it seems that the magnitude of covariance is not necessarily meaningful; it can be confused by the scale of the values taken by the random variables.

While we're at it, we might generalize the calculation above to see exactly how covariance responds to scalar multiplication: \Cov(\alpha X, \beta Y) \amp = \E(\alpha X \cdot \beta Y) - \E(\alpha X)\E(\beta Y) \amp = \alpha \beta \E(XY) - \alpha \beta \E(X)\E(Y) \amp = \alpha \beta \left(\E(XY) - \E(X)\E(Y)\right) \amp = \alpha \beta \Cov(X, Y).

Let X, Y be random variables with nonzero standard deviations \sigma_X, \sigma_Y, respectively. The correlation of X and Y is: \rho_{X, Y} \amp = \frac{\Cov(X, Y)}{\sigma_X \sigma_Y} = \frac{\Cov(X, Y)}{\sqrt{\sigma_X^2 \sigma_Y^2}}

We first observe that standard deviations are never negative, so the sign of the correlation will always match the sign of the covariance. It remains to be seen whether the magnitude of the correlation can be usefully interpreted.

Let's see how the correlation responds to scaling the random variables. We know \Var(\alpha X) = \alpha^2 \Var(X) and \Var(\beta Y) = \beta^2 \Var(Y), so: \rho_{\alpha X, \beta Y} \amp = \frac{\Cov(\alpha X, \beta Y)}{\sqrt{\Var(\alpha X)\Var(\beta Y)}} \amp = \frac{\alpha \beta \Cov(X, Y)}{\sqrt{\alpha^2 \beta^2 \Var(X) \Var(Y)}} \amp = \frac{\alpha \beta \Cov(X, Y)}{|\alpha \beta| \sqrt{\Var(X) \Var(Y)}} \amp = \pm \rho_{X, Y}. Note the minus sign that could show up when you take the square root of the square of a constant. This makes perfect sense, conceptually: the sign information was meant to tell us whether X and Y get bigger together, or whether one gets bigger while the other gets smaller. If we multiply only one of them by a negative constant, we flip its values upside down, so it makes sense for the sign of both the covariance and the correlation to switch in this case. But the interesting thing here is the magnitude, which did not change when the individual random variables were scaled. This gives some hope that the magnitude of the correlation can be meaningfully interpreted.

Consider the joint and marginal distributions below (from ):

<tabular halign="center"> <row bottom="minor"> <cell right="minor"/> <cell right="minor"><m>X = 0</m></cell> <cell><m>X = 1</m></cell> </row> <row bottom="minor"> <cell right="minor"><m>Y = 0</m></cell> <cell right="minor">0.2</cell> <cell>0.1</cell> </row> <row> <cell right="minor"><m>Y = 1</m></cell> <cell right="minor">0.2</cell> <cell>0.5</cell> </row> </tabular> </table> <table> <title/> <tabular halign="center"> <row bottom="minor"> <cell><m>x</m></cell> <cell><m>\Pr(X = x)</m></cell> </row> <row> <cell>0</cell> <cell>0.4</cell> </row> <row> <cell>1</cell> <cell>0.6</cell> </row> </tabular> </table> <table> <title/> <tabular halign="center"> <row bottom="minor"> <cell><m>y</m></cell> <cell><m>\Pr(Y = y)</m></cell> </row> <row> <cell>0</cell> <cell>0.3</cell> </row> <row> <cell>1</cell> <cell>0.7</cell> </row> </tabular> </table> </sidebyside> <p> We previously calculated <m>\E(X) = 0.6, \E(Y) = 0.7, \Cov(X, Y) = 0.08</m>, so <m>\Var(X) = (0.6)(0.4) = 0.24</m> and <m>\Var(Y) = (0.7)(0.3) = 0.21</m>, and: <md> <mrow> \rho_{X, Y} = \frac{\Cov(X, Y)}{\sqrt{\Var(X) \Var(Y)}} = \frac{0.08}{\sqrt{(0.24)(0.21)}} \approx 0.356. </mrow> </md> </p> </example> <example> <p> What can we say if <m>X</m> and <m>Y</m> are linearly related? Suppose <m>\E(X) = \mu</m> and <m>\Var(X) = \sigma^2</m>, and let <m>Y = aX + b</m>. Then: <md> <mrow> \E(Y) \amp = \E(aX + b) = a \E(X) + b = a \mu + b </mrow> <mrow> \Var(Y) \amp = \Var(aX + b) = a^2\Var(X) = a^2\sigma^2 </mrow> <mrow> \E(XY) \amp = \E(X(aX + b)) = \E(aX^2 + bX) = a \E(X^2) + b \mu </mrow> </md> Since <m>\Var(X) = \E(X^2) - (\E(X))^2</m>, we have <m>\E(X^2) = \Var(X) + (\E(X))^2</m>. Therefore: <md> <mrow> \E(XY) \amp = a(\sigma^2 + \mu^2) + b \mu = a\sigma^2 + a \mu^2 + b\mu </mrow> </md> Now we can calculate the covariance and correlation: <md> <mrow> \Cov(X, Y) \amp = \E(XY) - \E(X)\E(Y) </mrow> <mrow> \amp = a \sigma^2 + a\mu^2 + b\mu - \mu(a\mu + b) </mrow> <mrow> \amp = a \sigma^2 + a\mu^2 + b\mu - a\mu^2 - b\mu </mrow> <mrow> \amp = a \sigma^2 </mrow> <mrow> \rho_{X, Y} \amp = \frac{a \sigma^2}{\sqrt{\sigma^2 \cdot a^2\sigma^2}} </mrow> <mrow> \amp = \frac{a \sigma^2}{|a| \sigma^2} </mrow> <mrow> \amp = \pm 1. </mrow> </md> It is a fact (not justified here) that <m>-1 \leq \rho_{X, Y} \leq 1</m> always. So, the above calculation shows that random variables in a linear relationship to one another are maximally correlated. </p> </example> <p> In the next section, we will investigate the ability of the correlation to capture linear relationships. </p> <exercises xml:id="exercises-Correlation"> <exercise> <statement> <p> Calculate the correlation of <m>X</m> and <m>Y</m>: </p> <table> <title/> <tabular halign="center"> <row header="yes" bottom="minor"> <cell right="minor"/> <cell right="minor"><m>X = 1</m></cell> <cell><m>X = 2</m></cell> </row> <row bottom="minor"> <cell right="minor"><m>Y = 0</m></cell> <cell right="minor">0.12</cell> <cell>0.24</cell> </row> <row> <cell right="minor"><m>Y = 1</m></cell> <cell right="minor">0.3</cell> <cell>34</cell> </row> </tabular> </table> </statement> </exercise> <exercise> <statement> <p> Calculate the correlation of <m>X</m> and <m>Y</m>: </p> <table> <title/> <tabular halign="center"> <row header="yes" bottom="minor"> <cell right="minor"/> <cell right="minor"><m>X = 0</m></cell> <cell right="minor"><m>X = 1</m></cell> <cell><m>X = 2</m></cell> </row> <row bottom="minor"> <cell right="minor"><m>Y = 0</m></cell> <cell right="minor">0.08</cell> <cell right="minor">0.16</cell> <cell>0.1</cell> </row> <row> <cell right="minor"><m>Y = 1</m></cell> <cell right="minor">0.14</cell> <cell right="minor">0.2</cell> <cell>0.32</cell> </row> </tabular> </table> </statement> </exercise> <exercise> <statement> <p> Suppose we roll a fair, 4-sided die two times. Let <m>X</m> be the sum of the rolls, and let <m>Y</m> be the product of the rolls. Find the correlation of <m>X</m> and <m>Y</m>. </p> <p> [Note: Somewhat tedious.] </p> </statement> </exercise> </exercises> </section>