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, ...)
Value
The nearest positive definite matrix of 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).