Completion of Assignment 2: Eigennumbers and Eigenvectors

Author

Ahmed MUSTAFA
(& Google Gemini)

Published

October 15, 2026

Small Exercise: Variance-Covariance Matrix and Eigen-Decomposition

NoteExercise Overview & Objective

Here, we analyze the joint return behavior of two investment assets, Asset X and Asset Z, under three different economic phases: Expansion, Normal growth, and Recession. We construct the variance-covariance matrix using vectors and matrix multiplication, and then calculate its eigenvalues and eigenvectors to understand the main direction of portfolio risk.

1. Defining Probabilities and Asset Returns Across Economic Phases

We first set up: - The probability vector \(\mathbf{p}\) for the three economic phases (summing to 1). - The return matrix \(\mathbf{R}\), where each row represents an economic phase and each column represents an asset’s return in percent.

\[\mathbf{p} = \begin{pmatrix} p_{\text{Expansion}} \\ p_{\text{Normal}} \\ p_{\text{Recession}} \end{pmatrix} = \begin{pmatrix} 0.25 \\ 0.45 \\ 0.30 \end{pmatrix}\]

\[\mathbf{R} = \begin{pmatrix} 12 & 21 \\ 10 & 14 \\ 8 & 9 \end{pmatrix}\]

Code
# Probabilities of the three economic phases (as decimals)
p <- c(Expansion = 0.25, Normal = 0.45, Recession = 0.30)

# Asset returns (%) across each economic phase
R <- matrix(
  c(12, 21,
    10, 14,
     8,  9),
  nrow = 3,
  byrow = TRUE,
  dimnames = list(
    c("Expansion", "Normal", "Recession"),
    c("Asset_X", "Asset_Z")
  )
)

p
Expansion    Normal Recession 
     0.25      0.45      0.30 
Code
R
          Asset_X Asset_Z
Expansion      12      21
Normal         10      14
Recession       8       9

2. Calculating the Variance-Covariance Matrix

To measure how each asset varies on its own and how both move together:

  1. Expected return (\(\boldsymbol{\mu}\)): Multiply each phase’s return by its likelihood.
  2. Deviation matrix (\(\mathbf{\tilde{R}}\)): Subtract the expected return from the returns in each economic phase.
  3. Variance-Covariance matrix (\(\mathbf{\Sigma}\)): Weight the squared deviations and cross-products by their probabilities using matrix multiplication.
Code
# 1. Expected return for each asset
mu <- t(R) %*% p
colnames(mu) <- "Expected_Return"

# 2. Difference between returns in each phase and the expected return
ones_vec  <- rep(1, length(p))
Deviation <- R - (ones_vec %*% t(mu))

# 3. Probability weight matrix along the diagonal
P_mat <- diag(p)

# 4. Variance-Covariance matrix
Variance_Covariance <- t(Deviation) %*% P_mat %*% Deviation
dimnames(Variance_Covariance) <- list(colnames(R), colnames(R))

mu
        Expected_Return
Asset_X            9.90
Asset_Z           14.25
Code
Deviation
          Asset_X Asset_Z
Expansion     2.1    6.75
Normal        0.1   -0.25
Recession    -1.9   -5.25
Code
Variance_Covariance
        Asset_X Asset_Z
Asset_X   2.190  6.5250
Asset_Z   6.525 19.6875
TipWhat the Covariance Matrix Shows
  • Variance of Asset X: \(2.19\) (standard deviation \(\approx 1.48\%\))
  • Variance of Asset Z: \(19.69\) (standard deviation \(\approx 4.44\%\))
  • Covariance between X and Z: \(6.525\)

Asset Z exhibits much wider swings across economic phases than Asset X, and the positive covariance shows that both assets move in the same direction. Both experience a gain during expansions and a drop during recessions.


3. Eigen-Decomposition

The eigenvalues (\(\lambda\)) and eigenvectors (\(\mathbf{v}\)) of the Variance-Covariance matrix (\(\mathbf{\Sigma}\)) satisfy the fundamental equation:

\[\mathbf{\Sigma} \mathbf{v} = \lambda \mathbf{v} \quad \Longleftrightarrow \quad (\mathbf{\Sigma} - \lambda \mathbf{I}) \mathbf{v} = \mathbf{0}\]

Non-trivial solutions exist when the characteristic polynomial equals zero:

\[\det(\mathbf{\Sigma} - \lambda \mathbf{I}) = 0\]

For a symmetric Variance-Covariance matrix, this yields the spectral decomposition:

\[\mathbf{\Sigma} = \mathbf{V} \mathbf{\Lambda} \mathbf{V}^T\]

where \(\mathbf{\Lambda} = \begin{pmatrix} \lambda_1 & 0 \\ 0 & \lambda_2 \end{pmatrix}\) is the diagonal matrix of eigenvalues, and \(\mathbf{V} = \begin{pmatrix} \mathbf{v}_1 & \mathbf{v}_2 \end{pmatrix}\) is the orthogonal matrix of eigenvectors.

The proportion of total portfolio risk explained by each component \(i\) is calculated as:

\[\text{Proportion}_i = \frac{\lambda_i}{\sum_{j} \lambda_j} \times 100\%\]

Eigenvalues tell us how much total risk is concentrated in each dimension, while eigenvectors give the direction (the asset combination) representing that risk.

Code
# Calculate eigenvalues and eigenvectors
eig_decomp <- eigen(Variance_Covariance, symmetric = TRUE)

lambda_vals <- eig_decomp$values
V_vecs      <- eig_decomp$vectors
dimnames(V_vecs) <- list(colnames(R), c("Component_1", "Component_2"))

lambda_vals
[1] 21.8527892  0.0247108
Code
V_vecs
        Component_1 Component_2
Asset_X   0.3149562  -0.9491062
Asset_Z   0.9491062   0.3149562
Code
# Percentage of total risk explained by each component
prop_variance <- (lambda_vals / sum(lambda_vals)) * 100
names(prop_variance) <- c("Component_1", "Component_2")

round(prop_variance, 2)
Component_1 Component_2 
      99.89        0.11 
NotePractical Interpretation

The first eigenvalue accounts for 99.89% of the total variance. Because this first component captures virtually all joint movement, diversification between Asset X and Asset Z across these three economic phases is limited. A broad economic downturn hurts both assets simultaneously.


4. Mathematical Checks

We verify our results using basic matrix properties:

  1. Total Variance Check: The sum of eigenvalues must equal the sum of the diagonal elements (the trace) of the Variance-Covariance matrix: \[\sum_{i=1}^k \lambda_i = \text{tr}(\mathbf{\Sigma})\]

  2. Determinant Check: The product of eigenvalues must equal the determinant of the Variance-Covariance matrix: \[\prod_{i=1}^k \lambda_i = \det(\mathbf{\Sigma})\]

  3. Definition Check: The matrix equation must hold with zero residual error: \[\mathbf{\Sigma} \mathbf{v}_1 = \lambda_1 \mathbf{v}_1\]

Code
# 1. Definition check: Variance_Covariance %*% v1 equals lambda1 * v1
v1 <- V_vecs[, 1]
lambda1 <- lambda_vals[1]
diff_norm <- max(abs((Variance_Covariance %*% v1) - (lambda1 * v1)))

# 2. Total variance: sum of eigenvalues vs trace
sum_lambdas  <- sum(lambda_vals)
matrix_trace <- sum(diag(Variance_Covariance))

# 3. Determinant: product of eigenvalues vs determinant
prod_lambdas <- prod(lambda_vals)
matrix_det   <- det(Variance_Covariance)

# Summary table comparing both methods
verification_matrix <- matrix(
  c(sum_lambdas, matrix_trace,
    prod_lambdas, matrix_det,
    diff_norm, 0),
  nrow = 3,
  byrow = TRUE,
  dimnames = list(
    c("Total Variance (Trace)", "Determinant", "Difference ||Av - lv||"),
    c("From_Eigenvalues", "From_Covariance_Matrix")
  )
)

verification_matrix
                       From_Eigenvalues From_Covariance_Matrix
Total Variance (Trace)     2.187750e+01                21.8775
Determinant                5.400000e-01                 0.5400
Difference ||Av - lv||     8.881784e-16                 0.0000
ImportantSummary

The checks confirm our calculations match exactly:

  • Total variance is \(21.8775\) under both methods.

  • The determinant is \(0.54\) under both methods.

  • The difference between the matrix product and the scalar-eigenvector product is practically zero, proving the calculation is exact.