is.posi_def {IMIFA}R Documentation

Check Positive-(Semi)definiteness of a matrix

Description

Tests whether all eigenvalues of a symmetric matrix are positive (or strictly non-negative) to check for positive-definiteness and positive-semidefiniteness, respectively. If the supplied matrix doesn't satisfy the test, the nearest matrix which does can optionally be returned.

Usage

is.posi_def(x,
            tol = NULL,
            semi = FALSE,
            make = FALSE)

Arguments

x

A matrix, assumed to be real and symmetric.

tol

Tolerance for singular values and for absolute eigenvalues - only those with values larger than tol are considered non-zero.

(default: tol = max(dim(x))*max(E)*.Machine$double.eps, where E is the vector of absolute eigenvalues).

semi

Logical switch to test for positive-semidefiniteness when TRUE or positive-definiteness when FALSE (the default).

make

Logical switch to return the nearest matrix which satisfies the test - if the test has been passed, this is of course just x itself, otherwise the nearest positive-(semi)definite matrix. Note that for reasons due to finite precision arithmetic, finding the nearest positive-definite and nearest positive-semidefinite matrices are effectively equivalent tasks.

Value

If isTRUE(make), a list with two components:

check

A logical value indicating whether the matrix satisfies the test.

X.new

The nearest matrix which satisfies the test (which may just be the input matrix itself.)

Otherwise, only the logical value indicating whether the matrix satisfies the test is returned.

Examples

x    <- cov(matrix(rnorm(100), nrow=10, ncol=10))
is.posi_def(x)                                           #FALSE
is.posi_def(x, semi=TRUE)                                #TRUE

Xnew <- is.posi_def(x, semi=FALSE, make=TRUE)$X.new
identical(x, Xnew)                                       #FALSE
identical(x, is.posi_def(x, semi=TRUE, make=TRUE)$X.new) #TRUE

[Package IMIFA version 2.2.0 Index]