Skip to main content
Ultra Feature. Requires an Ultra subscription. Get started at api.mathematicalcompany.com
What is this? When you need to model dependence across three or more markets simultaneously, vine copulas decompose the problem into a tree of pairwise copulas. This lets you capture complex multi-market dependencies that simple correlation matrices miss. Use it for portfolio-level tail risk analysis and multi-market stress testing.

Vine Copulas

Vine copulas extend bivariate copulas to model dependence among three or more markets. Where a single bivariate copula captures the relationship between two markets, a vine copula decomposes a high-dimensional dependence structure into a cascade of bivariate copulas arranged in a tree structure. Horizon implements both C-vine (canonical) and D-vine (drawable) constructions. All computation runs in Rust via PyO3.

C-Vine

Star-shaped tree with a central node. Best when one market dominates the dependence structure.

D-Vine

Path-shaped tree. Best when markets form a sequential dependence chain.

Tail Risk

Compute joint tail probabilities across many markets simultaneously.

Pipeline Integration

hz.vine_risk_monitor() tracks multi-market tail risk in real time within hz.run().

Why Vine Copulas?

Bivariate copulas work well for pairs of markets, but portfolio risk depends on the joint behavior of many markets simultaneously. The challenge is that most multivariate copula families (e.g., multivariate Gaussian, multivariate t) impose a single dependence structure across all pairs. Vine copulas solve this by:
  1. Pair-by-pair flexibility: each pair of markets can have its own copula family (Clayton for one pair, Gumbel for another)
  2. Tail dependence heterogeneity: some pairs can exhibit lower-tail dependence while others exhibit upper-tail dependence
  3. Scalability: the vine structure decomposes an n-dimensional problem into n*(n-1)/2 bivariate problems
Vine copulas build on the bivariate copula module. See the Copula Dependence page for details on the underlying copula families (Gaussian, Clayton, Gumbel, Frank).

API

VineType Enum

hz.fit_vine

Fit a vine copula to multivariate uniform data. The function selects the best bivariate copula family for each pair from Gaussian, Clayton, Gumbel, and Frank.
Returns a VineCopulaResult.

VineCopulaResult Type

PairCopula Type

Each pair copula in the vine decomposition.

Sampling

hz.vine_sample

Generate multivariate correlated samples from a fitted vine copula.
Returns list[tuple[float, ...]]: n samples, each of dimension vine.n_dimensions.

Tail Risk

hz.vine_tail_risk

Compute joint tail probabilities from a fitted vine copula. Estimates the probability that all (or a subset of) markets simultaneously fall below (or exceed) specified quantiles.
Returns float: estimated joint tail probability.
Joint tail probabilities are estimated via Monte Carlo simulation from the fitted vine. Increase n_simulations for more precise estimates of rare tail events. For a 4-market joint 5% tail event, 100,000 simulations typically provide 2 significant digits of precision.

Pipeline Integration

hz.vine_risk_monitor

Pipeline function that fits a vine copula across all monitored markets and injects tail risk metrics into ctx.params["vine_risk"].
The ctx.params["vine_risk"] dict contains:

C-Vine vs D-Vine

When to Use C-Vine

C-vine (canonical vine) uses a star-shaped tree where one central variable is connected to all others at each level. Use C-vine when:
  • One market dominates the dependence structure (e.g., BTC in crypto prediction markets)
  • You want to condition all other pairwise relationships on the most connected market
  • The most correlated variable can be identified a priori

When to Use D-Vine

D-vine (drawable vine) uses a path-shaped tree where variables form a sequential chain. Use D-vine when:
  • Markets have a natural ordering (e.g., sequential election primaries)
  • Dependence is strongest between “neighboring” markets
  • No single variable dominates the dependence structure

Mathematical Background

Bedford and Cooke (2001) showed that any n-dimensional copula density can be decomposed into a product of n*(n-1)/2 bivariate copula densities arranged in a nested tree structure called a regular vine (R-vine).For n=4, the decomposition produces 6 pair copulas across 3 tree levels:
  • Tree 1: 3 unconditional pairs
  • Tree 2: 2 conditional pairs (conditioned on 1 variable)
  • Tree 3: 1 conditional pair (conditioned on 2 variables)
C-vine and D-vine are special cases of R-vine with specific tree topologies.
Beyond tree 0, pair copulas are fit to conditional distributions. The conditional CDF F(x|z) is computed using the h-function:h(u|v; theta) = dC(u,v; theta) / dvEach bivariate copula family has a closed-form h-function. The h-function transforms observations to conditional uniform marginals, which are then used to fit the next tree level.
At each edge of the vine, fit_vine evaluates all four copula families (Gaussian, Clayton, Gumbel, Frank) and selects the best by AIC. This means different edges can use different families, providing maximum flexibility. The total vine AIC is the sum of all pair copula AICs.
Joint tail probabilities are computed via Monte Carlo simulation from the fitted vine. The vine sampling algorithm (Aas et al., 2009) proceeds sequentially through the tree levels:
  1. Sample the first variable uniformly
  2. For each subsequent variable, sample conditionally using the inverse h-function
  3. Count the fraction of samples where all variables fall below (or above) the specified quantile
This captures the full heterogeneous tail dependence structure of the vine, unlike methods that assume a single copula family for all pairs.
Vine copula fitting requires at least n*(n-1)/2 parameters for n markets. With many markets (n > 10), the number of pair copulas grows quadratically. Ensure you have sufficient observations (at least 30 per pair copula) for reliable estimation.