Performing Experiments in Python
Luke Hayden
Instructor
Basis
Relate one continuous or ordinal variable to another
Will variation in one predict variation in the other?
Pearson correlation
Pearson correlation
Parametric
Based on raw values
Sensitive to outliers
Assumes:
Effect measure
Spearman correlation
Non-parametric
Based on ranks
Robust to outliers
Assumes:
Effect measure
Pearson's r: 1, Spearman's rho = 1
Pearson's r: -1, Spearman's rho = -1
Pearson's r: 0.915, Spearman's rho = 1
Pearson's r: 0.0429, Spearman's rho = 0.0428
from scipy import stats
pearcorr = stats.pearsonr(oly.Height, oly.Weight)
print(pearcorr)
(0.6125605419882442, 7.0956520885987905e-190)
spearcorr = stats.spearmanr(oly.Height, oly.Weight)
print(spearcorr)
SpearmanrResult(correlation=0.728877815423366, pvalue=1.4307959767478955e-304)
Performing Experiments in Python