Learn R Programming

sfsmisc (version 0.9-5)

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.
symmetric
logical, simply passed to eigen.
eps.ev
number specifying the tolerance to use, see Details below.

Value

  • a matrix of the same dimensions as m but with the property to be positive definite.

Details

We form the eigen decomposition $$m = V \Lambda V'$$

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