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?

mkt
  • 18,245
  • 11
  • 73
  • 172
  • 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)