nearestPD {Karen}R Documentation

Nearest Positive Definite Matrix

Description

This function first check if a matrix A is positive definite, typically a correlation or variance-covariance matrix. If A is not positive definite, this function computes the nearest positive definite matrix of A using the function nearPD from package Matrix.

Usage

nearestPD(A, ...)

Arguments

A

numeric n \times n approximately positive definite matrix, typically an approximation to a correlation or covariance matrix. If A is not symmetric (and ensureSymmetry is not false), symmpart(A) is used.

...

Further arguments to be passed to nearPD (see package Matrix for details).

Value

The nearest positive definite matrix of A.

Examples

nearestPD(diag(c(1,0,1)))

[Package Karen version 1.0 Index]