Build a Better Process

Covariance Matrix for Investment Modeling

Learning statistics and investments at the same time can be confusing. Case in point, did you know a covariance matrix is the same as a variance-covariance matrix?
  1. Define - Define a covariance matrix for investments.
  2. Context - Use it in a sentence.
  3. Video - See the video for the concepts.
  4. Script - Follow along with the transcript below.
  5. Quiz - Test yourself.
face pic by Paul Alan Davis, CFA
Updated: February 17, 2021
The covariance matrix can easily be transformed into the more interpretable correlation matrix. Learn more below.

Outline Back Tip Next

/ factorpad.com / fin / glossary / covariance-matrix.html

An ad-free and cookie-free website.

Covariance Matrix


Covariance Matrix is a convenient structure for storing variance and covariance figures for securities and factors. Covariance represents the co-movements between securities and can be generated using a single-variable linear regression. Alternatively, in a multi-variable regression it is common to use factors to measure co-movements. The matrix is used for the evaluation and analysis of risk and for portfolio construction.

Synonym: variance-covariance matrix

For context, think of the covariance matrix sitting in the background behind portfolio risk analysis software that aids in mean variance optimization and risk measurement. When constructed on an asset-by-asset basis it is a square matrix with the dimensions of the number of securities squared. So for a 30 stock portfolio its dimensions are 30-by-30, so 900 total covariance calculations. When constructed using fundamental factors like size, style and momentum, the number of dimensions shrinks materially.

In a Sentence

Doc:  Because variance-covariance is redundant let's use covariance matrix from here forward.
Tom:  So it's like calling it tuna insted of ahi tuna?


This video can be accessed in a new window or App , at the YouTube Channel or from below.

Covariance matrix definition for investment modeling (4:29)

Video Script

The script includes two sections where we visualize and demonstrate the calculation of the covariance matrix.


We're sitting here in Excel, and this is a snippet from our boot camp course.

This is one depiction of the covariance matrix, generated using the monthly returns for four stocks located on the Returns tab.

In this state, the covariance matrix isn't very interpretable to the naked eye, and useful for analysis, but that's not what it is for. It sits behind software for portfolio analysis and optimization.

If you'd like to brush up on the calculation of covariance, there will be a link to the video at the end.

A correlation matrix, like this, is interpretable because the scale of correlation ranges from -1 to +1. It is created from the covariance matrix. The creation of the covariance matrix helps, so let's head there now.


We will create a covariance matrix for four stocks.

So third-party risk model providers use linear algebra in statistical programming languages to generate the covariance matrix at scale for thousands of securities, but here we'll calculate one manually in Excel.

There are three types of covariance matrices: historical, single-index and multi-factor. We are using the easiest one here called historical.

The matrix structure is actually borrowed form linear algebra and is used for matrix multiplication, which we cover in the boot camp.

Set up a table like this with matching rows and column labels for holding the co-movements between each stock. And if you notice, down the diagonal in blue, is the calculation for covariance of a stock versus itself, which mathematically is variance, and that's where the name name variance-covariance matrix comes from, but it is more clear to call it a covariance matrix.

In the first cell, use the sample covariance using the =COVARIANCE.S function, then open parenthesis, select the first array, comma, second array, closed parenthesis and Enter. That's the variance of Microsoft.

Next, in the next row, we do the same thing but use the returns on Microsoft, then eBay and come up with a covariance of 0.0016 for the pair of stocks. See how it matches with this cell, logically.


Click box for answer.

A stock-by-stock covariance matrix for 3 stocks has 9 unique cells. | True or False?

False, 6 unique cells total, 3 variances and 3 covariance pairs

To populate a factor-based covariance matrix requires a multifactor linear regression. | True or False?


Questions or Comments?

Still unclear on the covariance matrix? Leave a question in the comments section on YouTube or check out the Quant 101 series, specifically the tutorial Create a Covariance Matrix.

Related Terms

Our trained humans found other terms in the category risk forecasting you may find helpful.

What's Next?

Keep the learning going. Subscribe, link and follow so you don't miss out.

Outline Back Tip Next

/ factorpad.com / fin / glossary / covariance-matrix.html

covariance matrix
variance-covariance matrix
stock risk calculation
covariance of stocks
investment co-movement
demeaned returns
forecast portfolio risk
portfolio optimization
risk model
investment modeling
risk analysis
investment risk
variance covariance matrix excel
portfolio covariance
portfolio risk analysis
stock risk measures

A newly-updated free resource. Connect and refer a friend today.