-
Notifications
You must be signed in to change notification settings - Fork 10
Spearman's rank correlation coefficient
Maurice HT Ling edited this page Aug 13, 2021
·
3 revisions
Purpose: To measure the strength of relationship between 2 variables.
Null hypothesis: Correlation coefficient = 0
Alternate hypothesis: Correlation coefficient ≠ 0.
Note: Spearman's correlation coefficient is defined as the Pearson's correlation coefficient between the rank variables; hence, a non-parametric measure.
Code:
>>> from scipy import stats
>>> X = [1, 2, 3, 4, 5]
>>> Y = [5, 6, 7, 8, 7]
>>> result = stats.spearmanr(X, Y)
>>> print("Spearman's correlation coefficient = %.3f" % result.correlation)
Spearman's correlation coefficient = 0.821
>>> print("p-value = %.3f" % result.pvalue)
p-value = 0.089
Copyright (c) 2008-2024, Maurice HT Ling
Refereed Publications and Technical Reports
Abstracts and Other Un-Refereed Works
Autobiographic Verses (Poems that I wrote) and My Sayings