from the sciPy library I used: scipy.stats.stats import pearsonr to calculate the correlation coefficient for two arrays and I got a value of: (0.80751532276005755, 0.19248467723994242).
I thought that I would have just got one value within the range -1 to +1, so I'm unsure how to interpret these two results. These are my two arrays:
x = [50,500,1500,2500]
y = [17, 6, 6, 194]
and I did:
pearsonr(x,y)
Thanks
– If the p-value is low (generally less than 0.05), then your correlation is statistically significant, and you can use the calculated Pearson coefficient.
Sig (2-tailed)– This is the two-tailed p-value evaluating the null against an alternative that the mean is not equal to 50. It is equal to the probability of observing a greater absolute value of t under the null hypothesis.
The correlation coefficient (expressed as r ) shows the direction and strength of a relationship between two variables. The closer the r value is to +1 or -1, the stronger the linear relationship between the two variables is.
Correlation is significant at the 0.05 level (2-tailed). (This means the value will be considered significant if is between 0.010 to 0,050).
pearsonr()
returns a two-tuple consisting of the correlation coefficient and the corresponding p-value:
For a further discussion, see http://www.eecs.qmul.ac.uk/~norman/blog_articles/p_values.pdf
I thought that I would have just got one value within the range -1 to +1
If you just need to the correlation coefficient, simply ignore the second element of the tuple (the p-value):
corrxy = pearsonr(x,y)[0]
It might be worth mentioning that there's also numpy.corrcoef()
, which computes the correlation matrix (without p-values).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With