What I want to do is the following:

Let's say I have two assets 1 and 2, and have a 2x2 covariance matrix.

Then I have two portfolios A and B made of weights from assets 1 and 2.

What I would like to do is create a 4x4 covariance matrix of assets 1 and 2 and portfolios A and B.

I know how to calculate the covariance of the portfolios to the assets, I'm interested if there's a 'shortcut' to creating the 4x4 matrix using matrix algebra vs. building it from parts.


1 Answer 1


If your two assets are denoted by random variables $X_1$, $X_2$, with 2x2 covariance matrix $\mathbf{Q}$ and the portfolios:

$$ Z_1 = w_{11} X_1 + w_{12} X_2 $$ $$ Z_2 = w_{21} X_1 + w_{22} X_2 $$


$Cov(Z_1, X_1) = w_{11}Cov(X_1,X_1) + w_{12} Cov(X_2, X_1)$ , etc.

In matrix algebra:

$$ \mathbf{Z} = \mathbf{W} \mathbf{X}$$

The 4x4 covariance matrix, is:

$$ \begin{bmatrix} \mathbf{Q} & \mathbf{QW^T} \\ \mathbf{WQ} & \mathbf{WQW^T} \\ \end{bmatrix} $$

Where W is the identity matrix you can verify this reduces to your intuition.

  • $\begingroup$ Appreciate it! How would you go about building the last part in code? In R for example $\endgroup$ Commented Feb 2, 2021 at 21:52
  • 2
    $\begingroup$ in pythons numpy you would just create the Q and W matrices, then uses a matrix multiplication method and then use a block method to piece them together. Look at numpy.array, numpy.matmul, and numpy.block $\endgroup$
    – Attack68
    Commented Feb 2, 2021 at 21:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.