● Model Explainer

Model explainer — theory, significance, and formulas.

We explain the background and principle of each model in plain language so that newcomers to finance can follow along.

PRO2016

Hierarchical Risk Parity (HRP)

Marcos López de Prado · Building Diversified Portfolios that Outperform Out of Sample (2016)

A machine-learning-based algorithm that avoids the covariance-matrix inversion Markowitz depends on by clustering similar assets and allocating weights more robustly.


01

In one line

An algorithm that sidesteps the biggest weakness of Markowitz optimization — the inverse of the covariance matrix — by first grouping assets into "clusters of things that move alike" and then splitting risk among those clusters.

02

Why it was created

Anyone who actually runs Markowitz optimization soon notices that the results get strange as the number of holdings grows: 99% on one name and 0.1% on another, or completely different weights when the inputs are perturbed by even a tiny amount.

The root cause is the "inverse of the covariance matrix (Σ⁻¹)" inside the Markowitz formula. When the number of holdings is large relative to the data length, that inverse becomes numerically unstable, and the instability propagates directly into the weights.

In 2016, López de Prado started from the question "what if we just don't invert the matrix at all?" and borrowed clustering techniques from machine learning to propose HRP.

03

How it works (3 steps)

HRP computes weights in three steps — let's walk through each with diagrams.

① Tree Clustering — bundling similar assets into a tree

First, all pairwise correlations (ρ) are converted into distances: d(i, j) = √(½ · (1 − ρᵢⱼ)). A correlation near 1 yields a distance near 0; a negative correlation produces a larger distance. The closest pair of assets is merged first, then the next-closest, and so on, building a tree structure (dendrogram). As shown below, "assets that move alike" naturally fall on the same branch, and "assets that move differently (e.g., a bond ETF like TLT)" join the tree last.

Hierarchical clustering dendrogram with horizontal cut showing different cluster partitions
Fig. 1
Generic dendrogram — data points are merged step-by-step by distance into a tree
Image: Stathis Sideris (original PNG, 2005) / Mhbrugman (SVG conversion, 2009), Wikimedia Commons, CC BY-SA 3.0. Used unmodified per the license.

The figure above shows the "general shape" of a dendrogram — close points pair up first, then progressively more distant groups merge, until all data is bound into one tree. As the dashed line illustrates, the number of clusters depends on where you cut. HRP uses this tree directly as the "asset cluster structure." The next figure shows the dendrogram this tool actually produces for a 6-holding example.

0.000.250.500.751.00AAPLMSFT005930035720SPYTLTTech USKR ITDISTANCEASSETS (sorted by similarity)
Fig. 2
A dendrogram derived from an asset distance matrix — step-by-step cluster formation (DIVA Quantizer example)
Conceptual diagram (produced by DIVA Quantizer) · Theory source: M. López de Prado, "Building Diversified Portfolios that Outperform Out of Sample," Journal of Portfolio Management, 2016.

② Quasi-Diagonalization — reordering the covariance matrix

The rows and columns of the covariance matrix are reordered using the "similar-assets adjacent" ordering from the dendrogram. The originally scattered values become concentrated along the diagonal — hence "quasi-diagonal". This ordering is the setup for the next step's recursive bisection.

Before sortingSimilar assets scattered1.00-0.100.300.550.300.78-0.101.00-0.10-0.10-0.10-0.100.30-0.101.000.420.780.300.55-0.100.421.000.420.550.30-0.100.780.421.000.300.78-0.100.300.550.301.00AAPLTLT005930SPY035720MSFTAAPLTLT005930SPY035720MSFTAfter sorting (Quasi-Diagonal)Large values cluster on the diagonal1.000.780.300.300.55-0.100.781.000.300.300.55-0.100.300.301.000.780.42-0.100.300.300.781.000.42-0.100.550.550.420.421.00-0.10-0.10-0.10-0.10-0.10-0.101.00AAPLMSFT005930035720SPYTLTAAPLMSFT005930035720SPYTLT
Fig. 3
Quasi-Diagonalization — covariance matrix before vs. after reordering
Conceptual diagram (produced by DIVA Quantizer) · Theory source: López de Prado (2016), the quasi-diagonalization step of HRP.

③ Recursive Bisection — split groups in two and allocate weights

Split the ordered list of assets in two. Compute each half's "cluster variance," and assign a smaller weight to the higher-variance half and a larger weight to the lower-variance half (inverse-variance allocation). Then split each half again and repeat recursively all the way down to individual assets. By the end, every asset has a weight.

The key point is that, unlike Markowitz, HRP never inverts the full covariance matrix Σ⁻¹. At each step you only compare "the variance of two halves," so even when the number of assets is large and the data window is short — conditions that make Σ numerically unstable — the result does not blow up. This is the core of HRP's robustness.

04

Where it is used

  • Gives more stable weights than Markowitz when the asset count is high and the data window is short
  • Designed so that a blow-up in one asset is contained within its cluster
  • Used in practice for weight selection in risk-parity ETFs and multi-asset funds
  • Especially well-suited to asset classes with short histories — crypto, newly launched ETFs, etc.
05

Limitations

HRP focuses on robust diversification rather than aggressively chasing expected return — it does not reach the "point on the efficient frontier" that Markowitz can offer in theory. The cluster results are also only meaningful if the correlation structure across assets stays reasonably stable over time.

06

Further reading

NEXT

Run the Hierarchical Risk Parity model on your own portfolio.

Enter your portfolio and the metrics explained above will appear as real numbers.