What Is the Inverse Covariance Matrix?

Understanding the inverse covariance matrix via the spectral decomposition.

In statistics and optimization, we often multiply a vector x\mathbf{x} by the inverse of its covariance matrix Σ\boldsymbol{\Sigma}:

Σ1x.(1) \boldsymbol{\Sigma}^{-1} \mathbf{x}. \tag{1}

For example, you see this in the probability density function of the multivariate normal distribution or in the analytic solution to mean–variance optimization. What does this operation do? I’ve written about this before, when I discussed the covariance matrix Σ\boldsymbol{\Sigma} as high-dimensional variance, but that was cursory at best. The goal of this post is to explore this operation in more detail.

If Σ\boldsymbol{\Sigma} is a 1×11 \times 1 matrix, then clearly x\mathbf{x} is a 11-vector, and this just normalizes the scalar value:

xσ2.(2) \frac{x}{\sigma^2}. \tag{2}

And if Σ\boldsymbol{\Sigma} is a diagonal P×PP \times P matrix, then clearly x\mathbf{x} is a PP-vector, and this just normalizes each component of x\mathbf{x}:

Σ1x=[x1/σ12x2/σ22xP/σP2].(3) \boldsymbol{\Sigma}^{-1} \mathbf{x} = \begin{bmatrix} x_1 / \sigma_1^2 \\ x_2 / \sigma_2^2 \\ \vdots \\ x_P / \sigma_P^2 \end{bmatrix}. \tag{3}

The interesting case is when Σ\boldsymbol{\Sigma} is a non-diagonal P×PP \times P matrix. In that case, we can visualize the operation via the eigendecomposition, sometimes called the spectral decomposition. Recall that the eigendecomposition of a square matrix is

Σ=QΛQ,(4) \boldsymbol{\Sigma} = \mathbf{Q} \boldsymbol{\Lambda} \mathbf{Q}^{\top}, \tag{4}

where Q\mathbf{Q} is a square matrix whose nn-th column is the nn-th eigenvector of Σ\boldsymbol{\Sigma} and where Λ\boldsymbol{\Lambda} is a diagonal matrix of associated eigenvalues {λ1,,λP}\{\lambda_1, \dots, \lambda_P \}. Since Q\mathbf{Q} is an orthonormal basis and Λ\boldsymbol{\Lambda} is a diagonal matrix, we can think of it as: rotate our data into a vector space in which the transformed data is orthogonal, scale in this space, and rotate back to the original vector space. If this kind of geometric interpretation makes no sense, please see my post on the singular value decomposition (SVD).

Now let’s see this in equations. Raising this matrix to a power can be simplified as:

Σn=(QΛQ)(QΛQ)(QΛQ)k times=QΛΛΛk timesQ=QΛkQ.(5) \boldsymbol{\Sigma}^n = \underbrace{\left( \mathbf{Q} \boldsymbol{\Lambda} \mathbf{Q}^{\top} \right) \left( \mathbf{Q} \boldsymbol{\Lambda} \mathbf{Q}^{\top} \right) \dots \left( \mathbf{Q} \boldsymbol{\Lambda} \mathbf{Q}^{\top} \right)}_{\text{$k$ times}} = \mathbf{Q} \underbrace{\boldsymbol{\Lambda} \boldsymbol{\Lambda} \dots \boldsymbol{\Lambda}}_{\text{$k$ times}} \mathbf{Q}^{\top} = \mathbf{Q} \boldsymbol{\Lambda}^k \mathbf{Q}^{\top}. \tag{5}

This works because Q\mathbf{Q} is orthonormal and thus

QQ=QQ=I,(6) \mathbf{Q} \mathbf{Q}^{\top} = \mathbf{Q}^{\top} \mathbf{Q} = \mathbf{I}, \tag{6}

where I\mathbf{I} is the identity matrix. And this means that Λk\boldsymbol{\Lambda}^k is just a diagonal matrix where each element is raised to the power kk.

It follows that the inverse matrix Σ1\boldsymbol{\Sigma}^{-1} is the original spectral decomposition but with Λ1\boldsymbol{\Lambda}^{-1} instead of Λ\boldsymbol{\Lambda}. And we can interpret multiplying a vector x\mathbf{x} by this inverse as follows:

z:=Qxrotate into orthogonal vector spacez~:=Λ1zscale by the eigenvaluesx~:=Qz~rotate back into original vector space(7) \begin{aligned} \mathbf{z} &:= \mathbf{Q}^{\top} \mathbf{x} && \text{rotate into orthogonal vector space} \\ \tilde{\mathbf{z}} &:= \boldsymbol{\Lambda}^{-1} \mathbf{z} && \text{scale by the eigenvalues} \\ \tilde{\mathbf{x}} &:= \mathbf{Q} \tilde{\mathbf{z}} && \text{rotate back into original vector space} \end{aligned} \tag{7}

What will this operation actually do? We can visualize it in Figure 11. In my mind, the geometric fact that jumps out the most is that when we divide by eigenvalues, we convert our ellipsoid into another ellipsoid, stretching along the dimension that originally was the smaller of the two. So for example, if Σ\boldsymbol{\Sigma} was the empirical covariance matrix of x\mathbf{x}, we would normalize a la Equation 22 but in PP dimensions. Variables of x\mathbf{x} with high variance get downweighted.

Figure 1. Step-by-step multiplication of random vectors x\mathbf{x} with the components of the spectral decomposition of their inverse covariance matrix Σ1\boldsymbol{\Sigma}^{-1}. (Left) Random samples x\mathbf{x} from a multivariate normal distribution. The red and black arrows are the axes of an ellipsoid, defined by the square root of the eigenvalues {λ1,λ2}\{\lambda_1, \lambda_2\} of Σ1\boldsymbol{\Sigma}^{-1}. (Middle left) The random vectors and ellipsoid after multiplication by Q\mathbf{Q}^{\top}, a rotation matrix. (Middle right) The random vectors and ellipsoid after further rescaling by {λ11,λ21}\{\lambda_1^{-1}, \lambda_2^{-1}\}. (Right) The random vectors and ellipsoid, rotated back into the original vector space by the rotation matrix Q\mathbf{Q}.

This might be surprising at first. Perhaps you expected this operation to “whiten” the data in the sense of being the multivariate analog to dividing by the standard deviation. But it makes sense that it is not, because as we saw above, if Σ\boldsymbol{\Sigma} is a digaonal matrix, then Σ1\boldsymbol{\Sigma}^{-1} is like dividing by variances, not standard deviations.

This suggests that to whiten the data, we simply need to multiply x\mathbf{x} by Σ\boldsymbol{\Sigma} raised to the power k=1/2k = -1/2. See Figure 22. We can see that after the initial rotation, dividing by the square root of the eigenvalues converts our ellipsoid into a sphere. The final rotation simply rotates the whitened data back into “data space”.

Figure 2. Figure 11 but with Σ1/2\boldsymbol{\Sigma}^{-1/2}. Thus, the ellipsoid is transformed into a circle, since each axis is divided by its the square root of its eigenvalue, i.e. by its singular value.

This should make sense if you understand the SVD and that the singular values are the square roots of the eigenvalues. To see this, think about the SVD of our data matrix:

X=USV.(8) \mathbf{X} = \mathbf{U S V}^{\top}. \tag{8}

Here, X\mathbf{X} has shape N×PN \times P, where NN is the number of observations and PP is again the dimensionality of our data. Intuitively, the singular values of a matrix X\mathbf{X} are in the units of X\mathbf{X}, since U\mathbf{U} and V\mathbf{V} are just rotations. And what are the eigenvalues? They’re the square of the singular values, since:

Σ:=XX=(USV)(USV)=VS2V.(9) \boldsymbol{\Sigma} := \mathbf{X}^{\top} \mathbf{X} = (\mathbf{U S V}^{\top})^{\top} (\mathbf{U S V}^{\top}) = \mathbf{V S}^2 \mathbf{V}^{\top}. \tag{9}

Geometrically, we stretch by X\mathbf{X}^{\top} and then by X\mathbf{X}—so we’re double stretching. See Suraj Rampure’s notes for a bit more detail. But the high-level point is that Σ1x \boldsymbol{\Sigma}^{-1} \mathbf{x} is the multivariate analog of normalizing by the variance, while Σ1/2x \boldsymbol{\Sigma}^{-1/2} \mathbf{x} is multivariate analog of normalizing by the standard deviation.

Finally, this means we can generalize to any power of kk of Σ\boldsymbol{\Sigma}. When kk is large, our data is stretched along it’s current direction. When kk is negative, the data is stretched in the opposite direciton. And when k0k \approx 0, then the data is unchanged (Figure 33).



Figure 3. Figures 11 and 22 but with other powers kk.

This view of the inverse covariance matrix is helpful in interpreting other operations. For example, consider this derivation, with hopefully obvious notation, where now u\mathbf{u} and v\mathbf{v} denote arbitrary vectors unrelated to the SVD:

uD1v=uQΛ1Qv=uQΛ1vQ=uQΛ1/2Λ1/2vQ=uQΛvQΛ.(10) \begin{aligned} \mathbf{u}^{\top} \mathbf{D}^{-1} \mathbf{v} &= \mathbf{u}^{\top} \mathbf{Q} \boldsymbol{\Lambda}^{-1} \mathbf{Q}^{\top} \mathbf{v} \\ &= \mathbf{u}_Q^{\top} \boldsymbol{\Lambda}^{-1} \mathbf{v}_Q \\ &= \mathbf{u}_Q^{\top} \boldsymbol{\Lambda}^{-1/2} \boldsymbol{\Lambda}^{-1/2} \mathbf{v}_Q \\ &= \mathbf{u}_{Q\Lambda}^{\top} \mathbf{v}_{Q\Lambda}. \end{aligned} \tag{10}

This shows that uD1v\mathbf{u}^{\top} \mathbf{D}^{-1} \mathbf{v} is just a standard Euclidean inner product uQΛvQΛ\mathbf{u}_{Q\Lambda}^{\top} \mathbf{v}_{Q\Lambda} after we rotate and whiten both vectors. The inverse matrix D1\mathbf{D}^{-1} tells us how to transform each vector into a space where the standard dot product is the correct notion of distance.

For a more complicated example, consider a common modeling assumption, which is that a variable xnRP\mathbf{x}_n \in \mathbb{R}^{P} is a linear function of a low-dimensional factor fnRK\mathbf{f}_n \in \mathbb{R}^K where KPK \ll P. We can write this in matrix notation as

X=FB+E,(11) \mathbf{X} = \mathbf{F} \mathbf{B} + \mathbf{E}, \tag{11}

where XRN×P\mathbf{X} \in \mathbb{R}^{N \times P}, FRN×K\mathbf{F} \in \mathbb{R}^{N \times K}, BRK×P\mathbf{B} \in \mathbb{R}^{K \times P}, and ERN×P\mathbf{E} \in \mathbb{R}^{N \times P}. Under some common assumptions, we can show that the covariance matrix of x\mathbf{x} is

Σx:=cov[x,x]=BΣfB+Σe.(12) \boldsymbol{\Sigma}_x := \text{cov}[\mathbf{x}, \mathbf{x}] = \mathbf{B}^{\top} \boldsymbol{\Sigma}_f \mathbf{B} + \boldsymbol{\Sigma}_{e}. \tag{12}

For more details, we see factor analysis. In this scenario, the Woodbury identity tells us how to invert our low-rank covariance matrix Σx\boldsymbol{\Sigma}_x:

Σx1=Σe1Σe1B(Σf1+BΣe1B)1BΣe1.(13) \boldsymbol{\Sigma}_x^{-1} = \boldsymbol{\Sigma}_{e}^{-1} - \boldsymbol{\Sigma}_{e}^{-1} \mathbf{B}^{\top} \left(\boldsymbol{\Sigma}_f^{-1} + \mathbf{B} \boldsymbol{\Sigma}_{e}^{-1} \mathbf{B}^{\top} \right)^{-1} \mathbf{B} \boldsymbol{\Sigma}_{e}^{-1}. \tag{13}

Now here’s the question: what does it mean to normalize an observation xn\mathbf{x}_n by this quantity? To understand, let’s rewrite this as

Σx1xn=Σe1xnΣe1B(Σf1+BΣe1B)1BΣe1xn=Σe1(xnBnf^n)=Σe1x~n,(14) \begin{aligned} \boldsymbol{\Sigma}_x^{-1} \mathbf{x}_n &= \boldsymbol{\Sigma}_{e}^{-1} \mathbf{x}_n - \boldsymbol{\Sigma}_{e}^{-1} \mathbf{B}^{\top} \left(\boldsymbol{\Sigma}_f^{-1} + \mathbf{B} \boldsymbol{\Sigma}_{e}^{-1} \mathbf{B}^{\top} \right)^{-1} \mathbf{B} \boldsymbol{\Sigma}_{e}^{-1} \mathbf{x}_n \\ &= \boldsymbol{\Sigma}_{e}^{-1} \left( \mathbf{x}_n - \mathbf{B}^{\top}_n \hat{\mathbf{f}}_n \right) \\ &= \boldsymbol{\Sigma}_{e}^{-1} \tilde{\mathbf{x}}_n, \end{aligned} \tag{14}

where f^n\hat{\mathbf{f}}_n is the generalized least squares estimator of the factor fn\mathbf{f}_n using weights Σe\boldsymbol{\Sigma}_e and Ridge penality Σf\boldsymbol{\Sigma}_f,

f^n:=(Σf1+BΣe1B)1BΣe1xn,(15) \hat{\mathbf{f}}_n := \left(\boldsymbol{\Sigma}_f^{-1} + \mathbf{B} \boldsymbol{\Sigma}_{e}^{-1} \mathbf{B}^{\top} \right)^{-1} \mathbf{B} \boldsymbol{\Sigma}_{e}^{-1} \mathbf{x}_n, \tag{15}

and where x~n\tilde{\mathbf{x}}_n is thus our observation residualized by its estimated factor. This is why, if you squint your eyes, parts of the Woodbury identity look like the normal equation for ordinary least squares. It’s a projection. In words, we can say: we estimate the factor component of xn\mathbf{x}_n, subtract that factor component out, and then whiten the residual against the idiosyncratic variances.

We can concretize this a bit with an example. In mean–variance optimization, one’s optimal portfolio position w\mathbf{w}^{\star} without costs or constraints is essentially one’s risk-adjusted alpha:

wΣ1a.(16) \mathbf{w}^{\star} \propto \boldsymbol{\Sigma}^{-1} \mathbf{a}. \tag{16}

In finance, people commonly assume a factor structure for Σ\boldsymbol{\Sigma}. See risk factor modeling for details. For example, we might want to explicitly model that two companies in the same industry “load” onto a shared industry factor and model their correlation through that factor rather than by directly estimating Σ\boldsymbol{\Sigma}. In this model, our optimal position is

wΣe1(aBf^).(17) \mathbf{w}^{\star} \propto \boldsymbol{\Sigma}_e^{-1} \left( \mathbf{a} - \mathbf{B}^{\top} \hat{\mathbf{f}} \right). \tag{17}

Given everything above, we can interpret this optimal position as our factor-residualized alpha, adjusted by its idiosyncratic risk. In words, we only care about the alpha that isn’t correlated to other alpha through a common factor, and then we rescale this residualized alpha by its idiosyncractic variance, such that, all things being equal, we take larger positions in less volatile names.