\( \newcommand{\bm}[1]{\boldsymbol{#1}} \newcommand{\textm}[1]{\textsf{#1}} \def\T{{\mkern-2mu\raise-1mu\mathsf{T}}} \newcommand{\R}{\mathbb{R}} % real numbers \newcommand{\E}{{\rm I\kern-.2em E}} \newcommand{\w}{\bm{w}} % bold w \newcommand{\bmu}{\bm{\mu}} % bold mu \newcommand{\bSigma}{\bm{\Sigma}} % bold mu \newcommand{\bigO}{O} %\mathcal{O} \renewcommand{\d}[1]{\operatorname{d}\!{#1}} \)

Exercises

Exercise 12.1 (Learning heavy-tailed financial graphs)

  1. Download market data corresponding to \(N\) assets (e.g., stocks or cryptocurrencies) during a period with \(T\) observations, and form the data matrix \(\bm{X}\in\R^{T\times N}\).

  2. Learn a Gaussian MRF graph: \[ \begin{array}{ll} \underset{\bm{w}\geq\bm{0}}{\textm{maximize}} & \textm{log gdet}(\mathcal{L}(\bm{w})) - \textm{Tr}(\mathcal{L}(\bm{w})\bm{S})\\ \textm{subject to} & \mathfrak{d}(\bm{w}) = \bm{1}, \end{array} \] where \(\bm{S}\) is the sample covariance matrix of the data, \(\mathcal{L}(\bm{w})\) is the Laplacian operator that produces the Laplacian matrix \(\bm{L}\) from the weights \(\bm{w}\), and \(\mathfrak{d}(\bm{w})\) is the degree operator that gives the degrees of the nodes.

  3. Learn a heavy-tailed MRF graph directly: \[ \begin{array}{ll} \underset{\bm{w}\geq\bm{0}}{\textm{maximize}} & \begin{aligned}[t] \textm{log gdet}(\mathcal{L}(\bm{w})) - \frac{N+\nu}{T}\sum_{t=1}^T \textm{log}\left(\nu + (\bm{x}^{(t)})^\T\mathcal{L}(\bm{w})\bm{x}^{(t)}\right) \end{aligned}\\ \textm{subject to} & \mathfrak{d}(\bm{w}) = \bm{1}, \end{array} \] where \(\bm{x}^{(t)}\) is the \(t\)th row of the data matrix \(\bm{X}\).

  4. Learn a heavy-tailed MRF graph by solving the sequence of Gaussianized problems for \(k=1,2,\dots\) \[ \begin{array}{ll} \underset{\bm{w}\geq\bm{0}}{\textm{maximize}} & \textm{log gdet}(\mathcal{L}(\bm{w})) - \textm{Tr}(\mathcal{L}(\bm{w})\bm{S}^k)\\ \textm{subject to} & \mathfrak{d}(\bm{w}) = \bm{1}, \end{array} \] where \(\bm{S}^k\) is the weighted sample covariance matrix \[ \bm{S}^k = \frac{1}{T}\sum_{t=1}^T w_t^k \times \bm{x}^{(t)}(\bm{x}^{(t)})^\T, \] with weights \(w_t^k = \frac{N + \nu}{\nu + (\bm{x}^{(t)})^\T\mathcal{L}(\bm{w}^k)\bm{x}^{(t)}}\).

  5. Plot the graphs and compare them visually.

  6. Compute the dendrogram for each of the graphs and compare them.

Exercise 12.2 (Hierarchical \(1/N\) portfolio)

  1. Download market data corresponding to \(N\) assets during a period with \(T\) observations, and form the data matrix \(\bm{X}\in\R^{T\times N}\).
  2. Learn the graph distance matrix based on \(i\)) a simple distance matrix from the distance between the time series of asset pairs, and \(ii\)) a heavy-tailed MRF graph formulation.
  3. Construct the hierarchical \(1/N\) portfolio.
  4. Plot the portfolio allocation and perform a backtest (comparing with the \(1/N\) portfolio).

Exercise 12.3 (Hierarchical risk parity (HRP) portfolio)

  1. Download market data corresponding to \(N\) assets during a period with \(T\) observations, and form the data matrix \(\bm{X}\in\R^{T\times N}\).
  2. Learn the graph distance matrix based on \(i\)) a simple distance matrix from the distance between the time series of asset pairs, and \(ii\)) a heavy-tailed MRF graph formulation.
  3. Construct the HRP portfolio.
  4. Plot the portfolio allocation and perform a backtest (comparing with the inverse-variance portfolio).

Exercise 12.4 (Hierarchical equal risk contribution (HERC) portfolio)

  1. Download market data corresponding to \(N\) assets during a period with \(T\) observations, and form the data matrix \(\bm{X}\in\R^{T\times N}\).
  2. Learn the graph distance matrix based on \(i\)) a simple distance matrix from the distance between the time series of asset pairs, and \(ii\)) a heavy-tailed MRF graph formulation.
  3. Construct the HERC portfolio.
  4. Plot the portfolio allocation and perform a backtest (comparing with the hierarchical \(1/N\) portfolio and HRP portfolio).

Exercise 12.5 (From minimum variance portfolio to hierarchical portfolio)

  1. Derive the inverse of the \(2\times2\) block matrix \[ \bSigma = \begin{bmatrix} \bSigma_A & \bSigma_{AB}\\ \bSigma_{BA} & \bSigma_{B} \end{bmatrix}, \] identifying the Schur complements of \(\bSigma_A\) and \(\bSigma_B\) defined, respectively, as \[ \begin{aligned} \bSigma_A^c &= \bSigma_A - \bSigma_{AB}\bSigma_B^{-1}\bSigma_{BA}\\ \bSigma_B^c &= \bSigma_B - \bSigma_{BA}\bSigma_A^{-1}\bSigma_{AB}. \end{aligned} \]

  2. Derive the global minimum variance portfolio \[ \begin{array}{ll} \underset{\w}{\textm{minimize}} & \w^\T\bSigma\w\\ \textm{subject to} & \w^\T\bm{1} = 1. \end{array} \] in the form (up to a scaling factor) \[ \w \propto \bSigma^{-1}\bm{1} = \begin{bmatrix} (\bSigma_A^c)^{-1} \bm{b}_A\\ (\bSigma_B^c)^{-1} \bm{b}_B \end{bmatrix}, \] where \[ \begin{aligned} \bm{b}_A &= \bm{1} - \bSigma_{AB}\bSigma_B^{-1}\bm{1}\\ \bm{b}_B &= \bm{1} - \bSigma_{BA}\bSigma_A^{-1}\bm{1}. \end{aligned} \]

  3. Rewrite the solution in the form \[ \w \propto \begin{bmatrix} \frac{1}{\nu\left(\bSigma_A^c, \bm{b}_A\right)} \w\left(\bSigma_A^c, \bm{b}_A\right)\\ \frac{1}{\nu\left(\bSigma_B^c, \bm{b}_B\right)} \w\left(\bSigma_B^c, \bm{b}_B\right) \end{bmatrix}, \] for properly defined (normalized) allocation \(\w(\bSigma, \bm{b})\) and measure of risk \(\nu(\bSigma, \bm{b})\).