Skip to content

Graphical lasso

Estimate sparse Gaussian precision matrices, verify a two-variable penalty example, and distinguish conditional links from marginal co-movement and causality.

Graphical lasso estimates a sparse inverse covariance matrix by adding an L1L_1 penalty to a Gaussian likelihood. For a quant studying a large set of returns or risk factors, it supplies an invertible dependence estimate together with a network of conditional relationships. Its sparsity assumption concerns the precision matrix, Θ=Σ−1\Theta=\Sigma^{-1}, rather than the covariance matrix Σ\Sigma.
In a multivariate Gaussian model, Θij=0\Theta_{ij}=0 means variables ii and jj are conditionally independent given all the other included variables. A nonzero off-diagonal entry creates an undirected edge. The conditioning set matters: changing the assets or factors in the model can change the graph. These are statistical relationships, not causal arrows. Friedman, Hastie and Tibshirani, §1.

What the penalty acts on

Under an iid Gaussian observation model, take nn aligned observations xt∈Rpx_t\in\mathbb{R}^p, centre each variable and define the empirical covariance matrix using the Gaussian maximum-likelihood divisor:
S=1n∑t=1n(xt−xˉ)(xt−xˉ)⊤.S=\frac1n\sum_{t=1}^{n}(x_t-\bar x)(x_t-\bar x)^\top.
Assume every included variable has positive empirical variance. This uses nn, rather than the n−1n-1 divisor of the usual unbiased sample covariance. The distinction changes the scale of the likelihood relative to a fixed penalty.
The off-diagonal-only convention used here is
Θ^=argmin⁡Θ≻0{−log⁡det⁡Θ+tr⁡(SΘ)+ρ∑i≠j∣Θij∣},ρ≥0.\widehat\Theta =\underset{\Theta\succ0}{\operatorname{argmin}} \left\{-\log\det\Theta+\operatorname{tr}(S\Theta) +\rho\sum_{i\ne j}\lvert\Theta_{ij}\rvert\right\}, \qquad \rho\ge0.
The constraint requires a symmetric positive definite matrix. The first two terms are the Gaussian negative log-likelihood after removing constants and a common n/2n/2 factor. The penalty encourages exact zeros among off-diagonal entries. The fitted covariance is W^=Θ^−1\widehat W=\widehat\Theta^{-1}. With ρ=0\rho=0 and invertible SS, the solution is S−1S^{-1}.
The sum counts both Θij\Theta_{ij} and Θji\Theta_{ji}; equivalently it is 2∑i<j∣Θij∣2\sum_{i<j}|\Theta_{ij}|. A formula summing only over i<ji<j therefore needs coefficient 2ρ2\rho to represent this same objective. Also check whether diagonals are penalised: the original paper includes them, while the off-diagonal-only formulation above matches the official scikit-learn formulation. Under this article's convention, W^ii=Sii\widehat W_{ii}=S_{ii}; with the original all-entry penalty, W^ii=Sii+ρ\widehat W_{ii}=S_{ii}+\rho.
Despite its name, this is not ordinary lasso regression with one chosen response. It estimates a symmetric precision matrix jointly. The original algorithm cycles through coupled lasso subproblems; fitting separate regressions and combining their selected neighbours is a different procedure. Original paper, §2.

Take a fictional empirical covariance of two dimensionless, standardised return variables:

S=(10.40.41),ρ=0.2.S=\begin{pmatrix}1&0.4\\0.4&1\end{pmatrix}, \qquad \rho=0.2.

For this two-variable case, the fitted covariance's off-diagonal entry is the soft-thresholded empirical entry:

W^12=max⁡(0.4−ρ,0),W^=(10.20.21).\widehat W_{12}=\max(0.4-\rho,0), \qquad \widehat W=\begin{pmatrix}1&0.2\\0.2&1\end{pmatrix}.

Inverting gives

Θ^=11−0.22(1−0.2−0.21)=(25/24−5/24−5/2425/24).\widehat\Theta =\frac1{1-0.2^2}\begin{pmatrix}1&-0.2\\-0.2&1\end{pmatrix} =\begin{pmatrix}25/24&-5/24\\-5/24&25/24\end{pmatrix}.
The precision off-diagonal is approximately −0.208333-0.208333, so the edge remains. Its negative sign does not mean negative conditional association: the partial correlation is
−Θ^12Θ^11Θ^22=0.2.-\frac{\widehat\Theta_{12}}{\sqrt{\widehat\Theta_{11}\widehat\Theta_{22}}}=0.2.

With only two variables there are no other variables to condition on, so this also equals their fitted correlation.

A direct optimality check is useful. On an active off-diagonal, the stationarity condition is −W^12+S12+ρsign⁡(Θ^12)=0-\widehat W_{12}+S_{12}+\rho\operatorname{sign}(\widehat\Theta_{12})=0. Here it is −0.2+0.4−0.2=0-0.2+0.4-0.2=0. At ρ≥0.4\rho\ge0.4, the off-diagonal can be zero and the fitted precision is the identity: the edge disappears.

For the fictional two-variable example, fitted covariance entry W12 falls from 0.4 to zero as the penalty rises from zero to 0.4. Precision magnitude falls from 0.4762 to zero along a curved path. At penalty 0.2, W12 is 0.2 and precision magnitude is 0.2083. Both are zero at penalties of 0.4 or higher.
For the fictional two-variable example, fitted covariance entry W12 falls from 0.4 to zero as the penalty rises from zero to 0.4. Precision magnitude falls from 0.4762 to zero along a curved path. At penalty 0.2, W12 is 0.2 and precision magnitude is 0.2083. Both are zero at penalties of 0.4 or higher.
Original exact two-variable penalty path. Entries and penalty are dimensionless. The curve shows a fitted model, not the recovery of a known market network.

This simple threshold formula is special to the two-variable problem. In higher dimensions the inverse couples the entries; thresholding every sample covariance independently does not generally solve graphical lasso.

Consider a separate illustrative Gaussian model with precision

Θ=(1−1/40−1/41−1/40−1/41),Σ=Θ−1=114(154141641415).\Theta=\begin{pmatrix} 1&-1/4&0\\ -1/4&1&-1/4\\ 0&-1/4&1 \end{pmatrix}, \qquad \Sigma=\Theta^{-1}=\frac1{14} \begin{pmatrix}15&4&1\\4&16&4\\1&4&15\end{pmatrix}.
The conditional graph is the chain AA–BB–CC: AA and CC are independent given BB. Yet Cov⁡(A,C)=1/14>0\operatorname{Cov}(A,C)=1/14>0. A missing precision edge does not require a missing covariance entry. This distinction is exactly why a sparse precision model can describe assets that all co-move marginally. The Gaussian zero-precision interpretation is developed in Stanford's covariance-model notes.
A fictional Gaussian model has conditional links A to B and B to C, with no A to C edge because precision entry ThetaAC is zero. Its marginal covariance graph has all three links, including Cov(A,C)=1/14. The precision has diagonal one and adjacent entries minus one quarter.
A fictional Gaussian model has conditional links A to B and B to C, with no A to C edge because precision entry ThetaAC is zero. Its marginal covariance graph has all three links, including Cov(A,C)=1/14. The precision has diagonal one and adjacent entries minus one quarter.
Original stipulated Gaussian chain, separate from the two-variable fit. Solid lines represent nonzero entries of the indicated matrix; the dashed gap on the left marks the absent conditional edge.

Outside the Gaussian model, a zero precision entry implies zero linear partial correlation, but does not generally establish conditional independence. Even under Gaussianity, a fitted zero is a modelling decision subject to sampling error, not proof that the population relationship is absent.

Using the estimate in quant work

For an asset network, inspect normalised partial correlations rather than comparing raw precision entries across different units. A uniform penalty is scale-sensitive, so standardise deliberately and estimate the scaling from training data. If fitting a correlation-scale covariance WzW_z with training standard-deviation matrix DD, return-scale covariance is DWzDDW_zD. A unit-variance correlation estimate is not yet a portfolio covariance in return units.

Choose the penalty against the task. Cross-validation of held-out likelihood addresses distributional prediction; it does not certify the selected edge set. For return data, preserve time order and keep centring, scaling and tuning inside each training window. Sparse Gaussian precision is a specific structural assumption; common latent factors, tail dependence and changing regimes can make its graph a poor description. It is not a tail-risk or contagion model by itself.

A Ledoit–Wolf covariance estimator instead shrinks covariance towards a target without requiring exact precision zeros. Neither approach guarantees improved portfolio performance. Numerical output also needs checking: symmetry, positive definiteness, solver residuals and consistency between returned covariance and precision. Mazumder and Hastie, §7 explains why an incompletely converged original glasso implementation can return matrices that are not exact inverses.
For the graph-reading foundation, Bayesian Networks and Markov Random Fields develops undirected separation and Markov blankets. The public link is a lesson preview; the full lesson requires membership.

Sources

Last updated
  • graphical lasso
  • precision matrix
  • gaussian graphical models
  • sparse estimation
  • conditional independence
← Back to the glossaryBack to top ↑