8

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?

aquaplane
  • 83
  • 4
  • Duplicate? https://stats.stackexchange.com/questions/131065/non-transitivity-of-correlation-correlations-between-gender-and-brain-size-and/131069#131069 – kjetil b halvorsen Nov 08 '20 at 15:31
  • 1
    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. – Don Hatch Nov 09 '20 at 00:29
  • 2
    Example - having umbrella and being wet from rain are negatively correlated but both are positively correlated with rain. – Maciej Piechotka Nov 09 '20 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". – fblundun Nov 30 '20 at 01:02

1 Answers1

16

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$).

Stephan Kolassa
  • 95,027
  • 13
  • 197
  • 357
  • 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 Nov 08 '20 at 14:17
  • 6
    @Dave this particular example is the case when two variables are negatively correlated and a third variable is a sum of the two. – Sextus Empiricus Nov 08 '20 at 14:21
  • 3
    @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 – aquaplane Nov 09 '20 at 06:35