Session Ready
Exercise

The covariance matrix

The covariance matrix is crucial in determining the portfolio variance in the general case of \(N\) assets. Remember that an element on row \(i\) and column \(j\) correspond to the covariance of the \(i\) th and \(j\) th return. Recall also that the covariance of two return series is the product between their volatilities and their correlation, and that the covariance of an asset return with itself is its variance.

In this exercise, you will compute and analyze the covariance and correlation matrix on the monthly returns of the four asset classes from the previous exercise. To refresh, these asset classes are equities, bonds, real estate, and commodities. To create these matrices, you will use the standard functions cov() and cor().

In your workspace are the monthly investments as returns, and the vector of standard deviations sds that you created previously.

Instructions
100 XP
  • Create a diagonal matrix that contains the variances on the diagonal. You can use the function diag() to do this, using a squared sds^2 as the only argument. Call this diag_cov.
  • Compute the covariance matrix of returns. Call this cov_matrix.
  • Compute the correlation matrix of returns. Call this cor_matrix.
  • Verify that the covariance between bond returns and equity returns equals the product of their standard deviations and correlation, by running the pre-loaded code. Do not alter this code.