Correlation & Covariance Cheat Sheet

Pearson and Spearman correlation, covariance matrices, interpreting correlation strength, and common correlation fallacies.

Last Updated: May 1, 2025

Covariance

ItemDescription
Cov(X,Y) = E[(X - mu_X)(Y - mu_Y)]How X and Y vary together — sign indicates direction of relationship
Cov > 0X and Y tend to increase together — positive relationship
Cov < 0X above mean when Y below mean — negative relationship
LimitationScale-dependent — changing units changes covariance value
Cov(X,X) = Var(X)Covariance of variable with itself is its variance
Covariance MatrixSymmetric matrix — diagonal = variances, off-diagonal = pairwise covariances

Pearson Correlation

ItemDescription
r = Cov(X,Y) / (sigma_X * sigma_Y)Normalized covariance — dimensionless, ranges from -1 to +1
r = 1.0Perfect positive linear relationship
r = -1.0Perfect negative linear relationship
r = 0No linear relationship (but could have nonlinear relationship)
Strength Guidelines|r|<0.3=weak, 0.3-0.5=moderate, 0.5-0.7=strong, >0.7=very strong
AssumptionsLinear relationship, continuous variables, no outliers, homoscedasticity

Spearman Rank Correlation

ItemDescription
rs = Pearson on ranked dataMeasures monotonic (non-necessarily linear) relationship
Advantage over PearsonRobust to outliers and non-linear monotonic relationships
Use WhenOrdinal data, outliers present, monotonic but not linear relationship
InterpretationSame -1 to +1 range as Pearson, but about rank agreement
Tied RanksSpearman handles ties with average rank assignment
Correlation with ordinalSpearman is preferred for Likert scales and ordinal categories

Correlation Pitfalls

ItemDescription
Spurious CorrelationTwo unrelated variables correlated by chance or common cause
Anscombe's QuartetFour datasets with identical correlations but vastly different patterns
Simpson's ParadoxTrend appears in groups but reverses when groups combined
Restriction of RangeNarrow range of values artificially reduces observed correlation
Correlation Matrix VisualizationHeatmap makes patterns obvious — use it before modeling
Pro Tip: Correlation does not imply causation. Confounding variables, reverse causation, and coincidence all produce correlations. Always consider the causal mechanism.