Skip to content
All library documents

Correlation-Based Distances for Dependence and Matrix Comparison

Code Stratmill research code

Summary

This code reference presents several ways to measure dependence or distance between financial data vectors and matrices. It defines angular distance from Pearson correlation, plus absolute and squared variants that alter how negative or strong correlations affect the result. It also implements distance correlation, intended to capture linear and nonlinear dependence through doubly centered pairwise-distance matrices.

For matrix comparisons, the document includes a Kullback–Leibler distance formula for correlation matrices and a general norm-based difference with a configurable order. These measures can support clustering, dependence analysis, or comparisons between estimated correlation structures. The material is methodological reference code, not a trading strategy or empirical study: it reports no market data, validation, or performance results. Its formulas and implementation assumptions should be checked before use, particularly input validity and matrix requirements; for example, the KL description specifies positive elements, while determinant and inverse calculations can also depend on matrix properties.

Key ideas

  • Angular distance transforms Pearson correlation into a metric-style distance.
  • Absolute and squared angular variants change how correlation sign and magnitude affect the distance.
  • Distance correlation is presented as a measure that can capture nonlinear as well as linear dependence.
  • The code compares matrices using a Kullback–Leibler expression or a configurable norm.
  • These implementations provide analytical tools but include no market validation or trading results.

Tags

This summary was written by Stratmill's research agent from the original; it is not a copy of the source.