j-LoGo Covariance

The j-LoGo Covariance is the inverse of a sparse precision matrix built on the Triangulated Maximally Filtered Graph (TMFG) of the correlations, a planar graph of 3 (N - 2) links that keeps the strongest co-movements (Massara, Di Matteo and Aste, 2017; Barfuss, Massara, Di Matteo and Aste, 2016). Every asset is linked only to its closest neighbours, so the matrix holds far fewer parameters than the sample covariance.

The formula for the j-LoGo Covariance starts from the K four-asset cliques and the M three-asset separators of the TMFG built on the similarities \((1 + \rho_{i , j}) / 2\) of the correlations \(\rho_{i , j}\), and adds the inverses of the sample covariances of the cliques and subtracts those of the separators, with Inv(S_c) the inverse of the sample covariance of the assets of c placed at their rows and columns and zero elsewhere:

\[J = \sum_{c=1}^{K} \text{Inv}(S_{c}) - \sum_{c=1}^{M} \text{Inv}(S_{c})\]

The covariance is its inverse:

\[\Sigma = J^{-1}\]

With four or fewer assets every pair is linked and it is the sample covariance. The precision matrix is zero for pairs that are not linked, so they co-move only through the assets between them.

Its parameters can be set, and it can be shown as a correlation matrix. The covariance matrix holds the variance of every asset and the covariance of every pair, the risk input of the mean-variance analysis of Markowitz (1952). With N assets it holds N (N + 1) / 2 numbers to estimate, and when N is not small compared to the number of periods T, the sample estimate is noisy and ill-conditioned: its smallest eigenvalues come out too small, and an optimizer that inverts it puts large weights on the combinations of assets that only look safe in the sample. The estimators differ in how they deal with this: by shrinking towards a structured target, by cleaning the eigenvalues, by weighting recent periods, by counting only large moves or by resisting outliers. Every estimate is annualized with the number of periods in a year.

Also known as: LoGo, TMFG covariance, sparse inverse covariance.

In the Finance Toolkit this is get_covariance_estimate with method="jlogo", the same function as Covariance Estimate.

Example · AAPL, MSFT, JNJ, XOM · 2021 to 2025

Install the Finance Toolkit with pip install financetoolkit -U, then call get_covariance_estimate:

from financetoolkit import Toolkit

toolkit = Toolkit(
    ["AAPL", "MSFT", "JNJ", "XOM"],
    api_key="FINANCIAL_MODELING_PREP_KEY",
    start_date="2021-01-01",
    end_date="2025-12-31",
)

toolkit.portfolio.get_covariance_estimate(method="jlogo")

Which returns:

References

  • Paper Massara, G. P., Di Matteo, T. and Aste, T. (2017). “Network Filtering for Big Data: Triangulated Maximally Filtered Graph.” Journal of Complex Networks, 5(2), 161-178.
  • Paper Barfuss, W., Massara, G. P., Di Matteo, T. and Aste, T. (2016). “Parsimonious Modeling with Information Filtering Networks.” Physical Review E, 94(6), 062306.
  • Library Referenced against Riskfolio-Lib’s covar_matrix (j-LoGo Covariance)
Share