# Correlation between X and XY

If I have two independent random variables X and Y, what is the correlation between X and the product XY? If this is unknown, I would be interested in knowing at least what happens in the specific case of X and Y being normal with zero mean, if that's easier to solve.

• What motivates this question? I wonder if it would be best if we also address something else here. Are you conducting a study in which you've created an XY variable for some reason? – gung - Reinstate Monica Jul 21 '17 at 13:00

### Solution

I take it that a valid solution will be one that expresses--if possible--the correlation in terms of the separate properties of the variables $X$ and $Y$. Computing the correlation will involve computing the covariances of monomials in $X$ and $Y$. It is economical to get this done all at once. Simply observe that

1. When $X$ and $Y$ are independent and $i$ and $j$ are powers, then $X^i$ and $Y^j$ are independent;

2. The expectation of a product of independent variables is the product of their expectations.

This will give formulas in terms of the moments of $X$ and $Y$.

That's all there is to it.

### Details

Write $\mu_i(X) = E(X^i)$, etc. for the moments. Thus, for any numbers $i,j,k,l$ for which the calculations make sense and produce finite numbers,

\eqalign{ \operatorname{Cov}\left(X^iY^j, X^kY^l\right) &= E\left(X^iY^j X^kY^l\right) - E\left(X^iY^j\right) E\left(X^kY^l\right) \\&= \mu_{i+k}(X)\mu_{j+l}(Y) - \mu_i(X)\mu_k(X)\mu_j(Y)\mu_l(Y).}

Note that the variance of any random variable is its covariance with itself, so we don't have to do any special calculation for variances.

It should now be obvious how to compute moments involving monomials, of any powers, of any finite number of independent random variables. As an application, apply this result to the definition of correlation, which is the covariance divided by the square roots of the variances:

\eqalign{\operatorname{Cor}(X,XY) &= \frac{\operatorname{Cov}(X^1Y^0, X^1Y^1)}{\sqrt{\operatorname{Cov}(X^1Y^0, X^1Y^0)\ \operatorname{Cov}(X^1Y^1, X^1Y^1)}} \\ &=\frac{\mu_2(X)\mu_1(Y) - \mu_1(X)^2\mu_1(Y)}{\sqrt{\left(\mu_2(X)-\mu_1(X)^2\right)\left(\mu_2(X)\mu_2(Y)-\mu_1(X)^2\mu_2(Y)^2\right)}} . }

There are various algebraic simplifications which you might choose if you wish to relate this to expectations, variances, and covariances of the original variables, but carrying them out here wouldn't provide any more insight.

Using the law of total covariance and independence of $X$ and $Y$, \begin{align} \mbox{Cov}(X,XY) &=E\mbox{Cov}(X,XY|Y)+\mbox{Cov}(EX|Y,EXY|Y) \\&=E(Y\mbox{Cov}(X,X)) +\mbox{Cov}(EX,YEX) \\&=E(Y\mbox{Var}X) +\mbox{Cov}(EX,YEX) \\&=EY\mbox{Var}X. \end{align} Using the law of total variance, and again, independence, \begin{align} \mbox{Var}(XY) &= E\mbox{Var}(XY|Y) + \mbox{Var} E(XY|Y) \\&= E(Y^2 (\mbox{Var}X|Y)) + \mbox{Var} (Y (EX|Y)) \\&= E(Y^2 \mbox{Var}X) + \mbox{Var} (Y EX) \\&= E(Y^2) \mbox{Var}X + (EX)^2\mbox{Var} Y \\&= \mbox{Var}X\mbox{Var}Y+(EY)^2 \mbox{Var}X + (EX)^2\mbox{Var} Y . \end{align} Note how $Y$ can be treated as a constant in any of the above inner conditional expectations, variances or covariances.

From the above covariance and variance, the correlation can, after some algebraic manipulations, be nicely expressed in terms of the two coefficients of variation as \begin{align} \mbox{corr}(X,XY) &=\frac1{\sqrt{ 1 + \frac{\text{Var}Y}{(EY)^2}\left(1 + \frac{(EX)^2}{\text{Var}X}\right) }}. \end{align}

A check of this result by simulation:

> n <- 1e+6
> x <- rexp(n,2)-2
> y <- rnorm(n,mean=5)
> cv2 <- function(x) var(x)/mean(x)^2
> 1/sqrt(1+cv2(y)*(1+1/cv2(x)))
[1] 0.844882
> cor(x,x*y)
[1] 0.8445373

• Nice, but I would like to kindly point out a couple of things: 1. On the third line of the second set of equations, should there be a parenthesis as in $E(Y^2\text{Var}X)+\text{Var}(YEX)$? 2. Are you sure that the person who asked the question follows the reasoning behind the different steps? E.g. That $E\text{Cov}(X, XY|Y)=EY\text{Cov}(X,X)$ is so because $Y$ is a given. I would suggest a minimal explanation for some of the steps. – Antoni Parellada Jul 21 '17 at 19:40
• Yes, I added some parenthesis that were missing and some explanation. I have to admit I prefer the answer of @whuber though. – Jarle Tufto Jul 21 '17 at 20:39

In the specific case of X and Y being random variables with zero means, then $\rho(XY,X) = 0$ because $\mathbb{E}(X^2Y) = \mathbb{E}[\mathbb{E}[ X^2Y | X]] = \mathbb{E}[X^2\mathbb{E}[Y|X]] = 0$. Hence $cov(XY,X) = \mathbb{E}(X^2Y) - \mathbb{E}(XY).\mathbb{E}(X) = 0$

The Linear Correlation between X and XY will be,

Corr(X,XY) = Cov(X,XY) / sqrt(var(X)*var(XY))

Cov(X,XY) = Summation((X-mean(X))(XY-mean(XY)) / n

n - sample size; var(X) = variance of X; var(XY) = variance of XY

• The question is about random variables, not about data. – whuber Jul 25 '17 at 14:15
• how can we find whether 2 random variables are correlated or not? Through data only right. Correct me if I'm wrong. Apologies. – Sam Gladio Jul 25 '17 at 14:26
• One computes correlation theoretically, using mathematical properties of random variables. It is very much the same thing as, say, computing the strength of a bridge design using the principles of Newtonian mechanics, compared to building bridges and testing them: there are distinct roles for theory and data and they should not be confused with one another. – whuber Jul 25 '17 at 15:29