Exercises
Exercise 12.1 (Learning heavy-tailed financial graphs)
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}\).
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.
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}\).
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)}}\).
Plot the graphs and compare them visually.
Compute the dendrogram for each of the graphs and compare them.
Exercise 12.2 (Hierarchical \(1/N\) portfolio)
- 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}\).
- 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.
- Construct the hierarchical \(1/N\) portfolio.
- Plot the portfolio allocation and perform a backtest (comparing with the \(1/N\) portfolio).
Exercise 12.3 (Hierarchical risk parity (HRP) portfolio)
- 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}\).
- 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.
- Construct the HRP portfolio.
- Plot the portfolio allocation and perform a backtest (comparing with the inverse-variance portfolio).
Exercise 12.4 (Hierarchical equal risk contribution (HERC) portfolio)
- 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}\).
- 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.
- Construct the HERC portfolio.
- 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)
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} \]
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} \]
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})\).