0
$\begingroup$

Consider the following data sets:

Set 1:

 X | Y
---+---
 1 | 1
 2 | 2
 5 | 5

Set 2:

 X | Y
---+---
 1 | 1
 2 | 4
 5 | 13

For both of these data sets, the Pearson correlation coefficient is 1.0 - they are in perfect linear relationship with each other. However, for the first set, the "magnitude" (excuse my lack of proper terminology) is "1", while in the second set, it is "3". Or roughly speaking, in the first set, Y increases by 1 for every increase in X by 1, while in the second set, Y increases by 3 for every increase in X by 1.

How can I determine this "magnitude" between the two variables in the differing cases?

$\endgroup$
0
$\begingroup$

You can fit the best-line and take the slope from there. Example using numpy:

>>> d1 = np.array([[1, 1], [2, 2], [4, 4]])
>>> d2 = np.array([[1, 1], [2, 4], [5, 13]])
>>> np.polyfit(x=d1[:, 0], y=d1[:, 1], deg=1)
array([  1.00000000e+00,  -7.69185075e-16])
>>> np.polyfit(x=d2[:, 0], y=d2[:, 1], deg=1)
array([ 3., -2.])
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.