0

data example : variable a{1, 0, 1, 0, 1, 0, 1, 0} variable b{0, 1, 0, 1, 0, 1, 0, 1}

can I use spearman method for this analysis?

  • Correlations are used for numeric values, you variables are binary, have a look at https://en.wikipedia.org/wiki/Phi_coefficient. – user2974951 Oct 01 '18 at 06:18

1 Answers1

0

Yes, you can apply both Spearman's and Pearson's correlations on the data. I went on and run both in Python using your data:

from scipy.stats.stats import pearsonr
from scipy.stats import spearmanr

a = [1, 0, 1, 0, 1, 0, 1, 0]
b = [0, 1, 0, 1, 0, 1, 0, 1]

print("PEARSON'S: ", pearsonr(a, b))
print("SPEARMAN'S: ", spearmanr(a, b))

The results were:

PEARSON'S:  (-1.0, 0.0)
SPEARMAN'S:  SpearmanrResult(correlation=-0.9999999999999998, pvalue=2.7369110631344156e-47)
Mohammad Sohaib
  • 123
  • 1
  • 4
  • thx for your comment, but I'm afraid that it wouldn't be proper for binary variables. What I'm required now I think is advice of statistics – Jungho Kim Oct 01 '18 at 06:38
  • In that case, @user2974951 correctly states that you should take a look at "Phi Coefficient". – Mohammad Sohaib Oct 01 '18 at 06:42
  • Thx again! do you know which package support a phi coeffiecient function? phi() just takes a square matrix. But I should deal with 2 by 1000 matrix. – Jungho Kim Oct 01 '18 at 06:52
  • You can use [Matthews Correlation Coefficient](http://scikit-learn.org/stable/modules/generated/sklearn.metrics.matthews_corrcoef.html) available in sklearn in python. – Mohammad Sohaib Oct 02 '18 at 09:59