Compute a Packed Representation of a Covariance Matrix
Compute a Packed Representation of a Covariance Matrix
Transform covariances matrices to a packed representation or compute the inverse transformation.
cov2theta(Sigma)theta2cov(theta)
Arguments
Sigma: an n-by-n real, symmetric positive definite matrix. Only the upper triangle is seen .
theta: a numeric vector of length n∗(n+1)/2 whose first n elements are positive.
Returns
A vector like theta (cov2theta) or a matrix like Sigma (theta2cov); see Details .
Details
An n-by-n real, symmetric, positive definite matrix Σ can be factorized as
Σ=R′R.Sigma=R′∗R.
The upper triangular Cholesky factor R can be written as
R=R1D−1/2Dσ1/2,R=R1/sqrt(D)∗sqrt(Ds),
where R1 is a unit upper triangular matrix and D=diag(diag(R1′∗R1))
and Ds=diag(diag(Sigma))
are diagonal matrices.
cov2theta takes Σ and returns the vector θ
of length n∗(n+1)/2 containing the log diagonal entries of Dσ followed by (in column-major order) the strictly upper triangular entries of R1. theta2cov computes the inverse transformation.