Class Dependence
java.lang.Object
com.quantfinlib.risk.Dependence
Rank-based dependence measures — what Pearson correlation misses.
Pearson (in
RiskMetrics.correlation) measures LINEAR
co-movement and is wrecked by a single outlier or a nonlinear (but
monotone) relationship; risk work needs the rank alternatives:
- Spearman's ρ — Pearson on the RANKS: "do they move in the
same order?", robust to outliers and any monotone transform.
Also the correlation FRTB's P&L attribution test is defined
on (
PnlAttribution); - Kendall's τ — the probability a random pair is concordant
minus discordant. Slower to compute (O(n²) here — fine at risk
sample sizes) but with the property copula work leans on:
for elliptical copulas,
ρ_pearson = sin(πτ/2)inverts τ into the copula correlation without distributional damage.
Ties get midranks (Spearman) / count as neither concordant nor discordant (Kendall τ-a — adequate for continuous return data, where exact ties are measure-zero; heavy-tie categorical data wants τ-b, out of scope and said so). Static, deterministic, research lane.
-
Method Summary
Modifier and TypeMethodDescriptionstatic doublekendallTau(double[] a, double[] b) Kendall's τ (tau-a) in [-1, 1]; O(n²).static doublepearsonFromKendall(double tau) The elliptical-copula bridge: Pearson ρ implied by a Kendall τ.static double[]ranks(double[] values) Midranks (average rank for ties), 1-based.static doublespearman(double[] a, double[] b) Spearman rank correlation in [-1, 1].
-
Method Details
-
spearman
public static double spearman(double[] a, double[] b) Spearman rank correlation in [-1, 1]. -
kendallTau
public static double kendallTau(double[] a, double[] b) Kendall's τ (tau-a) in [-1, 1]; O(n²). -
pearsonFromKendall
public static double pearsonFromKendall(double tau) The elliptical-copula bridge: Pearson ρ implied by a Kendall τ. -
ranks
public static double[] ranks(double[] values) Midranks (average rank for ties), 1-based.
-