# correlation: the difference of two correlations is positive, but the correlation of the difference is negative?

There are 3 random variables, $$X_1$$, $$X_2$$ and $$Y$$. We know $$corr(X_2, Y)>corr(X_1, Y)>0$$, but $$corr(X_2 - X_1, Y)<0$$

In other words, $$X_2$$ is more positively correlated to $$Y$$ than $$X_1$$, but the difference ($$X_2-X_1$$) is actually negatively correlated with $$Y$$.

Is this possible? and can you construct such random variables?

• Correlation is not linear right?
– BCLC
Feb 4, 2023 at 17:54
• @BCLC: 'Correlation' without further qualification, especially when represented by the $\mathrm{corr}$ operator, means Pearson correlation. Feb 6, 2023 at 7:29

It is possible. Simple algebra shows that \begin{align} \rho_{X_2 - X_1, Y} = \frac{\sigma_{X_2}\rho_{X_2, Y} - \sigma_{X_1}\rho_{X_1, Y}}{\sigma_{X_2 - X_1}}. \end{align} So although $$\rho_{X_2, Y} > \rho_{X_1, Y}$$, the sign can be flipped if $$\sigma_{X_1} \gg \sigma_{X_2}$$. Following this observation, a valid counterexample can be easily constructed as $$(X_1, X_2, Y) \sim N_3(0, \Sigma)$$, where \begin{align} \Sigma = \begin{bmatrix} 100 & 0 & 2 \\ 0 & 1 & 0.3 \\ 2 & 0.3 & 1 \end{bmatrix}. \end{align} In this case, $$0 < \rho_{X_1, Y} = 0.2 < \rho_{X_2, Y} = 0.3$$, but $$\sigma_{X_2} = 1 < \sigma_{X_1} = 10$$. In addition, the joint distribution of $$(X_2 - X_1, Y)$$ is $$N_2(0, \Sigma')$$, where \begin{align} \Sigma' = \begin{bmatrix} 101 & -1.7 \\ -1.7 & 1 \end{bmatrix}. \end{align} Hence $$\rho_{X_2 - X_1, Y} = \frac{-1.7}{\sqrt{101 \times 1}} < 0$$.

• Ah yes, I guess in short: this is quite possible when $X_1$ has a much larger scale than $X_2$. Thanks for the quick solution. My pitfall when thinking about this was that when I visualize these 3 vectors in my head, I always visualize them having the same length, which would make this impossible. This is perhaps a pitfall that I have committed quite a few times before. Feb 4, 2023 at 23:16

A small example in R:

X1 <- c(0, 1, 3)
X2 <- c(0, 1, 2)
Y  <- c(0, 1, 2)

cor(X1, Y)
# 0.9819805  # sqrt(27/28)
cor(X2, Y)
# 1
cor(X2-X1,Y)
# -0.8660254 # -sqrt(3/4)


It would not be possible with covariance, as cov(X2-X1, Y) = cov(X2, Y) - cov(X1, Y)