# Calculating the correlation between difference scores from the correlations within timepoints

For a meta-analysis I am conducting, I need to know the correlation between two sets of difference scores.

For example, imagine a study in which the researchers measure variables $x$ and $y$ at time 1 and time 2, yielding $x_1$ ($x$ measured at time 1), $x_2$ ($x$ measured at time 2), $y_1$ ($y$ measured at time 1), and $y_2$ ($y$ measured at time 2). One can then calculate the difference scores $x_{diff}$ and $y_{diff}$ by taking $x_2 - x_1$ and $y_2 - y_1$, respectively. What I need is the correlation, $cor(x_{diff}, y_{diff})$.

However, many researchers do not report the correlation between these difference scores. In the example that I gave, the researcher might, for example, report a correlation table for the relationships between $x_1$, $x_2$, $y_1$, and $y_2$, but might not include $x_{diff}$ and $y_{diff}$ in this table.

How would I express $cor(x_{diff}, y_{diff})$ as a function of the correlations between $x_1$, $x_2$, $y_1$, and $y_2$? Is there any other information about $x$ and $y$ that I would need to calculate $cor(x_{diff}, y_{diff})$?

Below are some simulated data in R to further illustrate my question.

set.seed(3214)

y1 <- rnorm(50)
y2 <- .7 * y1 + rnorm(50)
y_diff <- y2 - y1

x1 <- .3 * y1 + rnorm(50)
x2 <- .8 * x1 + rnorm(50)
x_diff <- x2 - x1

# How do I express the correlation between x_diff and y_diff in terms of the other variables?
round(cor(cbind(x1, x2, x_diff, y1, y2, y_diff)), digits = 2)

x1    x2 x_diff    y1    y2 y_diff
x1      1.00  0.62  -0.09  0.19  0.26   0.12
x2      0.62  1.00   0.72 -0.02  0.04   0.08
x_diff -0.09  0.72   1.00 -0.19 -0.18  -0.01
y1      0.19 -0.02  -0.19  1.00  0.69  -0.26
y2      0.26  0.04  -0.18  0.69  1.00   0.53
y_diff  0.12  0.08  -0.01 -0.26  0.53   1.00


Where

• $\Delta X = x_2 - x_1$
• $\Delta Y = y_2 - y_1$

For simplicity in notation I presume all of the variables in the levels are mean centered, and so we have:

$$\text{Cov}(\Delta X,\Delta Y) = \text{Cov}(x_2 - x_1,y_2 - y_1)$$

Because of the mean centering, we can write the covariance in terms of the expectation of the product:

$$\text{E}[\Delta X \cdot \Delta Y] = \text{E}[(x_2 - x_1) \cdot (y_2 - y_1)]$$

Expanding out the right hand side because of bilinearity of expectation gives:

$$\text{E}[x_2y_2] - \text{E}[x_2y_1] - \text{E}[x_1y_2] + \text{E}[x_1y_1]$$

Which is just a set of covariances:

$$\text{Cov}(x_2,y_2) - \text{Cov}(x_2,y_1) - \text{Cov}(x_1,y_2) + \text{Cov}(x_1,y_1)$$

To extend this to correlations it is a bit more tedious. We have:

$$\text{Cor}(\Delta X,\Delta Y) = \frac{\text{Cov}(\Delta X,\Delta Y)}{\sqrt{\text{Var}(\Delta X)\cdot\text{Var}(\Delta Y)}}$$

So we have the numerator and now we need to figure out the denominator. Note that $\text{Var}(\Delta X) = \text{Var}(x_2) + \text{Var}(x_1) - 2\text{Cov}(x_1,x_2)$ and so then the denominator is:

$$\sqrt{[\text{Var}(x_2) + \text{Var}(x_1) - 2\text{Cov}(x_1,x_2)]\cdot[\text{Var}(y_2) + \text{Var}(y_1) - 2\text{Cov}(y_1,y_2)]}$$

There may be other simplifications possible, but they aren't obvious to me offhand. Here are the calculations for your data to show the equivalence (to within rounding error). Long story short, if you have all of the variances and covariances in the levels you can figure out the applicable variances and covariances in the differences.

set.seed(3214)

y1 <- rnorm(50)
y2 <- .7 * y1 + rnorm(50)
y_diff <- y2 - y1

x1 <- .3 * y1 + rnorm(50)
x2 <- .8 * x1 + rnorm(50)
x_diff <- x2 - x1

#same within rounding
num <- cov(x2,y2) - cov(x1,y2) - cov(x2,y1) + cov(x1,y1)
cov(y_diff,x_diff)
num

#same within rounding
den <- sqrt((var(x2) + var(x1) - 2*cov(x1,x2))*
(var(y2) + var(y1) - 2*cov(y1,y2)))
cor(y_diff,x_diff)
num/den

• This is perfect! Thank you very much. By the way, there's a typo in the final line of your answer -- $-0.1$ should be $-.01$. I tried to edit your answer but couldn't because the suggested correction was too few characters. Nov 17, 2014 at 19:21
• Using my simulated data, I noticed a slight discrepancy between $cor(x_2, y_2) - cor(x_2, y_1) - cor(x_1, y_2) + cor(x_1, y_1)$ and $cor(x_{diff}, y_{diff})$ -- the former yields $-0.01005702$, whereas the latter yields $-0.01157623$. The difference seems too large to be due to rounding error. Any idea what's going on? Nov 17, 2014 at 19:34
• Just to follow up, I noticed that $cov(x_2, y_2) - cov(x_2, y_1) - cov(x_1, y_2) + cov(x_1, y_1)$ yields the same result as $cov(x_{diff}, y_{diff})$ -- $-0.01211094$. So, I'm guessing that the source of the discrepancy has something to do with the standard deviations of $x_1$, $x_2$, $y_1$, and $y_2$. Nov 17, 2014 at 19:43
• Yes, I was hasty, and it doesn't quite carry through to correlations. I'm pretty sure it can still be written up as function of the levels, so I will work on it a bit to make it a better answer for the correlations. Nov 17, 2014 at 19:46
• There you go @PatrickS.Forscher. I was wrong about the simplification to correlations, but the same logic is extendable to only knowing a set of variances/covariances in the levels you can figure out the variances and covariances in the differences. Nov 17, 2014 at 20:05