+ 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
+ ):
+
+
+
+
+
+
+
+ |
+ X = 0 |
+ X = 1 |
+
+
+
+ | Y = 0 |
+ 0.2 |
+ 0.1 |
+
+
+
+ | Y = 1 |
+ 0.2 |
+ 0.5 |
+
+
+
+
+
+
+
+
+ | x |
+ \Pr(X = x) |
+
+
+
+ | 0 |
+ 0.4 |
+
+
+
+ | 1 |
+ 0.6 |
+
+
+
+
+
+
+
+
+ | y |
+ \Pr(Y = y) |
+
+
+
+ | 0 |
+ 0.3 |
+
+
+
+ | 1 |
+ 0.7 |
+
+
+
+
+
+
+ We previously calculated
+ \E(X) = 0.6, \E(Y) = 0.7, \Cov(X, Y) = 0.08, so
+ \Var(X) = (0.6)(0.4) = 0.24 and
+ \Var(Y) = (0.7)(0.3) = 0.21, and:
+
+ \rho_{X, Y} = \frac{\Cov(X, Y)}{\sqrt{\Var(X) \Var(Y)}} = \frac{0.08}{\sqrt{(0.24)(0.21)}} \approx 0.356.
+
+
+
+
+
+
+ What can we say if X and Y are linearly related?
+ Suppose \E(X) = \mu and \Var(X) = \sigma^2, and let
+ Y = aX + b.
+ Then:
+
+ \E(Y) \amp = \E(aX + b) = a \E(X) + b = a \mu + b
+ \Var(Y) \amp = \Var(aX + b) = a^2\Var(X) = a^2\sigma^2
+ \E(XY) \amp = \E(X(aX + b)) = \E(aX^2 + bX) = a \E(X^2) + b \mu
+
+ Since \Var(X) = \E(X^2) - (\E(X))^2, we have
+ \E(X^2) = \Var(X) + (\E(X))^2.
+ Therefore:
+
+ \E(XY) \amp = a(\sigma^2 + \mu^2) + b \mu = a\sigma^2 + a \mu^2 + b\mu
+
+ Now we can calculate the covariance and correlation:
+
+ \Cov(X, Y) \amp = \E(XY) - \E(X)\E(Y)
+ \amp = a \sigma^2 + a\mu^2 + b\mu - \mu(a\mu + b)
+ \amp = a \sigma^2 + a\mu^2 + b\mu - a\mu^2 - b\mu
+ \amp = a \sigma^2
+ \rho_{X, Y} \amp = \frac{a \sigma^2}{\sqrt{\sigma^2 \cdot a^2\sigma^2}}
+ \amp = \frac{a \sigma^2}{|a| \sigma^2}
+ \amp = \pm 1.
+
+ It is a fact (not justified here) that
+ -1 \leq \rho_{X, Y} \leq 1 always.
+ So, the above calculation shows that random variables in a linear
+ relationship to one another are maximally correlated.
+
+
+
+
+ In the next section, we will investigate the ability of the correlation
+ to capture linear relationships.
+
+
+
+
+
+
+ Calculate the correlation of X and Y:
+
+
+
+
+
+
+ |
+ X = 1 |
+ X = 2 |
+
+
+
+ | Y = 0 |
+ 0.12 |
+ 0.24 |
+
+
+
+ | Y = 1 |
+ 0.3 |
+ 34 |
+
+
+
+
+
+
+
+
+
+ Calculate the correlation of X and Y:
+
+
+
+
+
+
+ |
+ X = 0 |
+ X = 1 |
+ X = 2 |
+
+
+
+ | Y = 0 |
+ 0.08 |
+ 0.16 |
+ 0.1 |
+
+
+
+ | Y = 1 |
+ 0.14 |
+ 0.2 |
+ 0.32 |
+
+
+
+
+
+
+
+
+
+ Suppose we roll a fair, 4-sided die two times.
+ Let X be the sum of the rolls, and let Y be
+ the product of the rolls.
+ Find the correlation of X and Y.
+
+
+
+ [Note: Somewhat tedious.]
+
+
+
+
+
\ No newline at end of file
diff --git a/source/sec-Covariance.ptx b/source/sec-Covariance.ptx
index 2843a09..b1b38d4 100644
--- a/source/sec-Covariance.ptx
+++ b/source/sec-Covariance.ptx
@@ -52,7 +52,7 @@
The joint distribution lets you find