# Is it possible for two random variables to be negatively correlated, but both be positively correlated with a third r.v.?

Would it be possible for two variables to be negatively correlated with one another, yet be positively correlated with a third variable? Are there any concrete examples?

• Commented Nov 8, 2020 at 15:31
• Random variables form a vector space, in which you're asking whether it's possible for two vectors to have negative dot product, while both having positive dot product with a third vector. The answer to that is yes. In fact, given any two variables/vectors, as long as they are not directly opposite each other, their angular bisector will have positive dot product with each of them. Commented Nov 9, 2020 at 0:29
• Example - having umbrella and being wet from rain are negatively correlated but both are positively correlated with rain. Commented Nov 9, 2020 at 13:31
• Another natural example: the indicator random variables for the events "Smith wins the competition", "Jones wins the competition", and "Either Smith or Jones wins the competition". Commented Nov 30, 2020 at 1:02

Certainly. Consider multivariate normally distributed data with a covariance matrix of the form

$$\begin{pmatrix} 1 & - & + \\ - & 1 & + \\ + & + & 1 \end{pmatrix}.$$

As an example, we can generate 1000 such observations with covariance matrix

$$\begin{pmatrix} 1 & -0.5 & 0.5 \\ -0.5 & 1 & 0.5 \\ 0.5 & 0.5 & 1 \end{pmatrix}$$

in R as follows:

library(mixtools)
set.seed(1)
xx <- rmvnorm(1e3,mu=rep(0,3),
sigma=rbind(c(1,-.5,.5),c(-.5,1,.5),c(.5,.5,1)))
cor(xx[,c(1,2)])
cor(xx[,c(1,3)])
cor(xx[,c(2,3)])


The first two columns are negatively correlated ($$\rho=-0.5$$), the first and the third and the second and the third are positively correlated ($$\rho=0.5$$).

• My first thought was to do a simulation like this, which certainly proves that such random variables exist. However, I still struggle to think of a practical place where such a relationship would exist.
– Dave
Commented Nov 8, 2020 at 14:17
• @Dave this particular example is the case when two variables are negatively correlated and a third variable is a sum of the two. Commented Nov 8, 2020 at 14:21
• @Dave The motivation for my asking the question is a good example. This question was actually motivated by portfolio construction - I was wondering if it’ll be possible to find e.g. two stocks whose returns are negatively correlated, despite them perhaps both being correlated to the broader asset class of stocks in general. So the simplest case of where this might happen would be in an equally weighted two-stock portfolio, where the returns of the two stocks are negatively correlated, but each would be positively correlated to portfolio returns Commented Nov 9, 2020 at 6:35