Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

isSymmetricPD

Test for symmetric positive (semi-)definiteness


Description

Function to test if a matrix is symmetric positive (semi)definite or not.

Usage

isSymmetricPD(M)

isSymmetricPSD(M, tol = 1e-04)

Arguments

M

A square symmetric matrix.

tol

A numeric giving the tolerance for determining positive semi-definiteness.

Details

Tests positive definiteness by Cholesky decomposition. Tests positive semi-definiteness by checking if all eigenvalues are larger than -ε|λ_1| where ε is the tolerance and λ_1 is the largest eigenvalue.

While isSymmetricPSD returns TRUE if the matrix is symmetric positive definite and FASLE if not. In practice, it tests if all eigenvalues are larger than -tol*|l| where l is the largest eigenvalue. More here.

Value

Returns a logical value. Returns TRUE if the M is symmetric positive (semi)definite and FALSE if not. If M is not even symmetric, the function throws an error.

Author(s)

Anders Ellern Bilgrau Carel F.W. Peeters <cf.peeters@vumc.nl>, Wessel N. van Wieringen

See Also

Examples

A <- matrix(rnorm(25), 5, 5)
## Not run: 
isSymmetricPD(A)

## End(Not run)
B <- symm(A)
isSymmetricPD(B)

C <- crossprod(B)
isSymmetricPD(C)

isSymmetricPSD(C)

rags2ridges

Ridge Estimation of Precision Matrices from High-Dimensional Data

v2.2.4
GPL (>= 2)
Authors
Carel F.W. Peeters [cre, aut], Anders Ellern Bilgrau [aut], Wessel N. van Wieringen [aut]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.