1
$\begingroup$

As an example, let's take var_a and var_b:

var_a <- c(0,10,10,9,12,10,10,0)

var_b <- c(5,7,6,5,7,7,8,7)

All points are arranged in chronological order.

Within var_a, I calculate the difference between each value and the preceding one, so that:

diff.var_a <- c(NA,10,0,-1,3,-2,0,-10)

Then I do the same with var_b:

diff.var_b <- c(NA,2,-1,-1,2,0,1,-1)

The correlation between var_a and var_b is 0.35, while the correlation between diff.var_a and diff.var_b is (remving the NAs) 0.75.

What I would like to achieve is to show if variations in var_a are related to variations in var_b.

My initial idea was simply to calculate Pearson's r for var_a and var_b. Then I thought that maybe using the difference between consecutive points might do a better job in highlighting how changes in one variable correspond to changes in the other, hence the correlation between diff.var_a and diff.var_b.

The correlation coefficients are quite different, and can results in different interpretations. So now I am a bit stumped and I don't know a) if I should stick to a simple correlation between var_a and var_b, and b) what kind of information does the difference between consecutive points actually convey.

Any suggestion is appreciated.

$\endgroup$
2
  • $\begingroup$ "To show if variations in var_a are related to variations in var_b," you compare the variations to each other. Comparing the original values of var_a and var_b does not address this question: it's irrelevant. $\endgroup$
    – whuber
    Commented May 21, 2021 at 17:19
  • 1
    $\begingroup$ Your comment actually proved quite useful to understand better the situation, thanks $\endgroup$
    – Ray
    Commented Jun 1, 2021 at 9:30

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.