What Is the Inverse Covariance Matrix?
Understanding the inverse covariance matrix via the spectral decomposition.
In statistics and optimization, we often multiply a vector by the inverse of its covariance matrix :
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 as high-dimensional variance, but that was cursory at best. The goal of this post is to explore this operation in more detail.
If is a matrix, then clearly is a -vector, and this just normalizes the scalar value:
And if is a diagonal matrix, then clearly is a -vector, and this just normalizes each component of :
The interesting case is when is a non-diagonal 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
where is a square matrix whose -th column is the -th eigenvector of and where is a diagonal matrix of associated eigenvalues . Since is an orthonormal basis and 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:
This works because is orthonormal and thus
where is the identity matrix. And this means that is just a diagonal matrix where each element is raised to the power .
It follows that the inverse matrix is the original spectral decomposition but with instead of . And we can interpret multiplying a vector by this inverse as follows:
What will this operation actually do? We can visualize it in Figure . 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 was the empirical covariance matrix of , we would normalize a la Equation but in dimensions. Variables of with high variance get downweighted.
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 is a digaonal matrix, then is like dividing by variances, not standard deviations.
This suggests that to whiten the data, we simply need to multiply by raised to the power . See Figure . 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”.
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:
Here, has shape , where is the number of observations and is again the dimensionality of our data. Intuitively, the singular values of a matrix are in the units of , since and are just rotations. And what are the eigenvalues? They’re the square of the singular values, since:
Geometrically, we stretch by and then by —so we’re double stretching. See Suraj Rampure’s notes for a bit more detail. But the high-level point is that is the multivariate analog of normalizing by the variance, while is multivariate analog of normalizing by the standard deviation.
Finally, this means we can generalize to any power of of . When is large, our data is stretched along it’s current direction. When is negative, the data is stretched in the opposite direciton. And when , then the data is unchanged (Figure ).
This view of the inverse covariance matrix is helpful in interpreting other operations. For example, consider this derivation, with hopefully obvious notation, where now and denote arbitrary vectors unrelated to the SVD:
This shows that is just a standard Euclidean inner product after we rotate and whiten both vectors. The inverse matrix 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 is a linear function of a low-dimensional factor where . We can write this in matrix notation as
where , , , and . Under some common assumptions, we can show that the covariance matrix of is
For more details, we see factor analysis. In this scenario, the Woodbury identity tells us how to invert our low-rank covariance matrix :
Now here’s the question: what does it mean to normalize an observation by this quantity? To understand, let’s rewrite this as
where is the generalized least squares estimator of the factor using weights and Ridge penality ,
and where 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 , 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 without costs or constraints is essentially one’s risk-adjusted alpha:
In finance, people commonly assume a factor structure for . 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 . In this model, our optimal position is
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.