Learn R Programming

bbricks (version 0.1.4)

pdsInverse: Inverse of a positive definite symmetric matrix

Description

Use Cholesky decomposition to calculate the inverse of S, where \(S = A'A\), A is a upper diagonal matrix. inv(S) = inv(A)inv(A)'.

Usage

pdsInverse(S, returnUpper = FALSE)

Arguments

S

a symmetric positive definitive matrix.

returnUpper

logical, return inv(A) if returnUpper=TRUE,return inv(S) if returnUpper=FALSE, default FALSE.

Value

A matrix, the inverse of "S".

Examples

Run this code
# NOT RUN {
Sigma = matrix(c(2,1,1,2),2,2)      # some positive definite symmetric matrix
pdsInverse(Sigma)                   # get inv(Sigma)
pdsInverse(Sigma,returnUpper=TRUE)  # get inv(A), where Sigma=A'A, A is upper triangle
# }

Run the code above in your browser using DataLab