Examples by Prof. Jacob Escobar, EGADE Business School, Tec de Monterrey
Covariance Matrix \(\left(H\right)\):
| \(\sigma_1^2\) | \(\sigma_{1,2}\) | \(\sigma_{1,3}\) |
| \(\sigma_{2,1}\) | \(\sigma_2^2\) | \(\sigma_{2,3}\) |
| \(\sigma_{3,1}\) | \(\sigma_{3,2}\) | \(\sigma_3^2\) |
\[ \sigma_{i,j} = \rho_{i,j} \sigma_i \sigma_j \]
Traditional decomposition:
\[H = \sigma \rho \sigma\]
Where \(\sigma\) and \(\rho\) are matrices:
\(\sigma =\)
| \(\sigma_1\) | \(0\) | \(0\) |
| \(0\) | \(\sigma_2\) | \(0\) |
| \(0\) | \(0\) | \(\sigma_3\) |
\(\rho =\)
| \(1\) | \(\rho_{1,2}\) | \(\rho_{1,3}\) |
| \(\rho_{2,1}\) | \(1\) | \(\rho_{2,3}\) |
| \(\rho_{3,1}\) | \(\rho_{3,2}\) | \(1\) |
Cholesky decomposition:
\[H = A^TA\]
Where \(A\) is a half-matrix:
\(A =\)
| \(a_{1,1}\) | \(a_{1,2}\) | \(a_{1,3}\) |
| \(0\) | \(a_{2,2}\) | \(a_{2,3}\) |
| \(0\) | \(0\) | \(a_{3,3}\) |
The procedure to calculate \(a_{i,j}\) is sequential, going from top-left to bottom-right:
\[a_{1,1} = \sigma_1^2\]
\[a_{i,i} = \left( \sigma_i^2 - \sum_{k=1}^{i-1} a_{k,i}^2 \right)^{\frac{1}{2}}\]
\[a_{i,j} = \frac{1}{a_{i,i}} \left( \sigma_{i,j} - \sum_{k=1}^{i-1} a_{k,i} a_{k,j} \right)\]
\[j = i+1,i+2,...,n\]
Fortunately, we already have a function in R to calculate the Cholesky factor \(A\): chol( )
By the way, not all matrices have a Cholesky decomposition or factorization. For starters, they must be square matrices, but more formally speaking they must be symmetric positive semidefinite. In practical terms, if \(H\) isn’t “positive semi definite” the procedure will fail because at some point it will try to get a square root of a negative number. Fortunately too, most real-life covariances matrices that you find will be positive semidefinite.
H <- matrix(c(1,0.5,0.5,0.5,1,0.5,0.5,0.5,1), 3, 3)
H## [,1] [,2] [,3]
## [1,] 1.0 0.5 0.5
## [2,] 0.5 1.0 0.5
## [3,] 0.5 0.5 1.0
A <- chol(H)
A## [,1] [,2] [,3]
## [1,] 1 0.5000000 0.5000000
## [2,] 0 0.8660254 0.2886751
## [3,] 0 0.0000000 0.8164966
# Validation:
t(A) %*% A## [,1] [,2] [,3]
## [1,] 1.0 0.5 0.5
## [2,] 0.5 1.0 0.5
## [3,] 0.5 0.5 1.0