← All notes

Statistical note

Correlation: Pearson, Spearman, and Kendall

Linear, monotonic, and concordance-based association, with confidence intervals and microscopy examples.

9 min read

Pearson’s coefficient measures linear association:

r=i(xixˉ)(yiyˉ)i(xixˉ)2i(yiyˉ)2.r=\frac{\sum_i(x_i-\bar{x})(y_i-\bar{y})}{\sqrt{\sum_i(x_i-\bar{x})^2\sum_i(y_i-\bar{y})^2}}.

Spearman’s ρ\rho applies Pearson correlation to ranks; Kendall’s τ\tau compares concordant and discordant pairs.

Linear, monotonic, and outlier-sensitive associations

from scipy import stats

phase_mass = [11, 14, 18, 22, 27, 31]
fluorescence = [8, 12, 17, 21, 26, 35]

pearson = stats.pearsonr(phase_mass, fluorescence)
print(pearson.statistic, pearson.pvalue, pearson.confidence_interval())
print(stats.spearmanr(phase_mass, fluorescence))
print(stats.kendalltau(phase_mass, fluorescence))

Case study: QPI and fluorescence

Correlating dry mass with fluorescence per cell can reveal association, but cells nested within fields violate ordinary independence. Correlation does not establish agreement, calibration, or causality. Plot the relationship, inspect nonlinear structure and influential points, and consider hierarchical modelling.

Functions: scipy.stats.pearsonr, spearmanr, and kendalltau.