Point biserial correlation coefficient - mauriceling/mauriceling.github.io GitHub Wiki

Purpose: To measure the strength of relationship between a binary variable (X) and continuous variable (Y).

Null hypothesis: Correlation coefficient = 0

Alternate hypothesis: Correlation coefficient ≠ 0.

Code:

>>> from scipy import stats
>>> X = [1, 0, 1, 0, 1]
>>> Y = [5, 6, 7, 8, 7]
>>> result = stats.pointbiserialr(X, Y)
>>> print("Point biserial correlation coefficient = %.3f" % result.correlation)
Point biserial correlation coefficient = -0.320
>>> print("p-value = %.3f" % result.pvalue)
p-value = 0.599

Reference

  1. Lev J. 1949. The Point Biserial Coefficient of Correlation. Annals of Mathematical Statistics 20(1), 125-126.