Learn R Programming

sfsmisc (version 0.95-8)

posdefify: Find a Close Positive Definite Matrix

Description

From a matrix m, construct a "close" positive definite one.

Usage

posdefify(m, method = c("someEVadd", "allEVadd"), symmetric, eps.ev = 1e-07)

Arguments

m
a numeric (square) matrix.
method
a string specifying the method to apply; can be abbreviated.
symmetric
logical, simply passed to eigen.
eps.ev
number specifying the tolerance to use, see Details below.

Value

  • a matrix of the same dimensions and the same diagonal (i.e. diag) as m but with the property to be positive definite.

Details

We form the eigen decomposition $$m = V \Lambda V'$$ where $\Lambda$ is the diagonal matrix of eigenvalues, $\Lambda_{j,j} = \lambda_j$, with decreasing eigenvalues $\lambda_1 \ge \lambda_2 \ge \ldots \ge \lambda_n$.

When the smallest eigenvalue $\lambda_n$ are less than Eps <- eps.ev * abs(lambda[1]), i.e., negative or almost zero, some or all eigenvalues are replaced by positive (>= Eps) values, $\tilde\Lambda_{j,j} = \tilde\lambda_j$. Then, $\tilde m = V \tilde\Lambda V'$ is computed and rescaled in order to keep the original diagonal (where that is >= Eps).

References

Section 4.4.2 of Gill, P.~E., Murray, W. and Wright, M.~H. (1981) Practical Optimization, Academic Press.

Cheng, Sheung Hun and Higham, Nick (1998) A Modified Cholesky Algorithm Based on a Symmetric Indefinite Factorization; SIAM J. Matrix Anal. Appl., 19, 1097--1110.

See Also

eigen on which the current methods rely.

Examples

Run this code
set.seed(12)
 m <- matrix(round(rnorm(25),2), 5, 5); m <- 1+ m + t(m); diag(m) <- diag(m) + 4
 m
 posdefify(m)
 1000 * zapsmall(m - posdefify(m))

Run the code above in your browser using DataLab