On this page
Hierarchical Risk Parity HRP: Clustering Instead of Inverting
Hierarchical risk parity is a portfolio construction algorithm that uses graph clustering on the correlation matrix to allocate weights, instead of inverting a covariance matrix. It was introduced by Marcos Lopez de Prado in 2016 to solve the instability of classical Markowitz optimization in high dimensions.
Key Takeaways
- Hierarchical risk parity HRP avoids matrix inversion entirely, using single-linkage clustering and inverse-variance recursive bisection to allocate capital through a correlation-based dendrogram.
- Lopez de Prado's 2016 paper reports out-of-sample variance reductions of roughly 30% versus classical mean-variance and other heuristic allocators across simulated and real datasets.
- In a 10-asset example with five equity-like and five bond-like assets, the top cluster split might allocate only 9% to equities and 91% to bonds if equity cluster variance is 10x higher, a dramatic tilt away from equal weighting.
- HRP is not parameter-free; the linkage method (single, complete, Ward) and distance metric produce different trees and weights, document and fix these choices as part of the strategy definition.
Key Takeaways
- Hierarchical risk parity HRP avoids matrix inversion entirely, using single-linkage clustering and inverse-variance recursive bisection to allocate capital through a correlation-based dendrogram.
- Lopez de Prado's 2016 paper reports out-of-sample variance reductions of roughly 30% versus classical mean-variance and other heuristic allocators across simulated and real datasets.
- In a 10-asset example with five equity-like and five bond-like assets, the top cluster split might allocate only 9% to equities and 91% to bonds if equity cluster variance is 10x higher, a dramatic tilt away from equal weighting.
- HRP is not parameter-free; the linkage method (single, complete, Ward) and distance metric produce different trees and weights, document and fix these choices as part of the strategy definition.
What It Is
The classical mean-variance optimizer requires inverting the covariance matrix Sigma. With many assets and few observations, that inverse amplifies noise dramatically, and the resulting weights swing wildly with small changes in input. Lopez de Prado's HRP algorithm avoids the inversion entirely. It builds a tree of asset clusters, then allocates capital top-down through that tree using inverse-variance weights at each split.
The 2016 Journal of Portfolio Management paper, "Building Diversified Portfolios that Outperform Out-of-Sample," reports out-of-sample variance reductions of roughly 30 percent versus classical mean-variance and other heuristic allocators across simulated and real datasets. The method is now standard in many systematic portfolio libraries.
The Intuition
Markowitz treats every asset as competing with every other asset directly. With 500 stocks, that means 124,750 pairwise relationships, all entering one matrix inversion. Real markets do not work that way. Stocks cluster into sectors, factors, and regions. Sectors cluster into broader risk segments. Adding noise to one stock should not propagate across the whole optimization.
HRP encodes that hierarchy. It clusters assets into groups based on correlation, then a bigger tree of groups, and so on. Inside each cluster, capital is split inversely to variance. Between clusters, capital is also split inversely to cluster variance. Because the algorithm only ever divides capital top-down through binary splits, no matrix inversion is needed and the procedure is numerically stable.
How It Works
The algorithm has three stages: tree clustering, quasi-diagonalization, and recursive bisection.
Stage 1, tree clustering. Convert the correlation matrix rho into a distance matrix:
d_ij = sqrt( 0.5 * (1 - rho_ij) )
d_ij is between 0 and 1. Use d as the distance matrix in a single-linkage hierarchical clustering algorithm, producing a dendrogram of asset groups.
Stage 2, quasi-diagonalization. Reorder the rows and columns of Sigma so that similar assets sit next to each other along the diagonal. The reordering follows the leaf order of the dendrogram from stage 1. The block-diagonal structure of the reordered matrix becomes visually obvious.
Stage 3, recursive bisection. Starting with the full asset list, split it into two halves following the dendrogram, then allocate capital between the halves inversely to each half's "cluster variance":
function allocate(items):
if length(items) == 1:
return weight_dict
left, right = split items into two halves following the dendrogram
var_left = w_inv_var(left)' * Sigma_left * w_inv_var(left)
var_right = w_inv_var(right)' * Sigma_right * w_inv_var(right)
alpha = 1 - var_left / (var_left + var_right)
scale weights inside left by alpha
scale weights inside right by (1 - alpha)
recursively call allocate(left) and allocate(right)
w_inv_var is the inverse-variance weight vector inside the cluster, and Sigma_left is the covariance submatrix of that cluster. The recursion descends until each leaf has a single asset. The product of all the splits gives final weights, which sum to 1.
Worked Example
Consider 10 assets clustered into two natural groups: 5 equity-like assets with moderate cross-correlations, and 5 fixed-income-like assets with low correlations to equities and moderate correlations to each other.
Stage 1 produces a dendrogram with the five equity names in one branch and the five bond names in another, joined at the top. Stage 2 reorders the covariance so equities form one block and bonds form another.
Stage 3 begins with the top split: equities on one side, bonds on the other. Inverse-variance inside each cluster gives starting weights. Suppose the equity cluster's variance, computed using its inverse-variance weights, is 0.020 and the bond cluster's is 0.002. Then:
alpha = 1 - 0.020 / (0.020 + 0.002) = 1 - 0.909 = 0.091
Equities receive 9.1 percent of capital total, bonds 90.9 percent. Inside each cluster, the recursion splits again, allocating capital among sub-clusters inversely to their variances. Final weights might end up close to 1 to 2 percent per equity and 18 percent per bond. Compared to a Markowitz solution with the same inputs, the HRP weights are far less concentrated and far more stable to small changes in the correlation matrix.
Common Mistakes
-
Treating it as parameter-free. HRP avoids inverting
Sigma, but it still depends on the correlation estimate, the linkage method, and the choice of distance. Single linkage, complete linkage, and Ward linkage produce different trees and therefore different weights. Document and stick to a single recipe. -
Skipping the comparison to inverse-variance and minimum variance. Lopez de Prado's experiments show HRP wins out-of-sample most of the time, but not always. Run the same backtest against simpler baselines so you know whether HRP is earning its complexity in your dataset.
-
Using too few observations. Hierarchical clustering on a noisy correlation matrix produces noisy trees. Even though HRP is more stable than Markowitz, it still benefits from longer histories or denoised correlations. Lopez de Prado's later work covers detoning and shrinkage of correlations specifically for clustering.
-
Confusing it with risk parity. Standard risk parity allocates so each asset contributes equally to total volatility. HRP allocates inversely to variance within clusters and recursively between clusters. The two methods can produce very different weights, especially when assets cluster strongly.
-
Ignoring rebalancing realism. HRP weights move when the dendrogram reorders. Small changes in correlation can flip cluster boundaries, producing larger turnover than a simple inverse-variance scheme. Pair HRP with banded rebalancing or a slow-moving correlation estimator to control trading costs.
Frequently Asked Questions
Q: What is hierarchical risk parity in simple terms? HRP is a portfolio allocation method that first clusters assets by their correlation structure into a tree, then allocates capital down through the tree using inverse-variance weights at each split. It produces stable weights without ever inverting the covariance matrix.
Q: How does hierarchical risk parity affect investment decisions? It provides a systematic, numerically stable way to diversify across many assets, especially useful when correlations are noisy and the covariance matrix is nearly singular. The resulting weights are typically more balanced and more stable across rebalancing periods than Markowitz-derived weights.
Q: What is a real-world example of hierarchical risk parity? A 10-asset portfolio with five equity-like assets (high variance, moderate cross-correlation) and five bond-like assets (low variance, moderate cross-correlation) produces a top-level cluster split. If equity cluster variance is 10x bond variance, HRP allocates only about 9% of capital to the entire equity cluster, far less than equal weighting would give.
Q: How can investors implement hierarchical risk parity? PyPortfolioOpt's HRP implementation and similar open-source libraries handle all three stages (distance clustering, quasi-diagonalization, recursive bisection) out of the box. Choose a linkage method (Ward linkage is popular for stability), pair with a denoised or shrunk correlation matrix, and add banded rebalancing rules to control turnover.
Q: How is hierarchical risk parity different from standard risk parity? Standard risk parity solves for weights that make every asset contribute the same amount to total portfolio variance, requiring a covariance matrix inversion. HRP allocates capital through a hierarchical tree using only within-cluster inverse-variance weights, avoiding the inversion. The two methods produce different weights and have different robustness properties in high-dimensional problems.
Sources
- Lopez de Prado, M. (2016). "Building Diversified Portfolios that Outperform Out-of-Sample." Journal of Portfolio Management, 42(4). https://papers.ssrn.com/sol3/papers.cfm?abstract_id=2708678
- Lopez de Prado, M. (2018). Advances in Financial Machine Learning. Wiley. https://www.wiley.com/en-us/Advances+in+Financial+Machine+Learning-p-9781119482086
- Raffinot, T. (2017). "Hierarchical Clustering-Based Asset Allocation." Journal of Portfolio Management, 44(2). https://papers.ssrn.com/sol3/papers.cfm?abstract_id=2840729
- PyPortfolioOpt. "Hierarchical Risk Parity Implementation." https://pyportfolioopt.readthedocs.io/en/latest/OtherOptimizers.html
Disclaimer
This article is educational content only and is not financial advice. Nothing here is a recommendation to buy, sell, or hold any security. Consult a licensed advisor before making investment decisions.