Adjust the diagonal of a symmetric square matrix, by the smallest eigenvalue method, in order to make it positive definite.
makePositiveDefinite(M1, M2 = NULL, threshold = 0.1)
A squared numeric matrix, typically a correlation or a covariance matrix. It must be symmetric.
A correction factor.
A list with the corrected input matrices and the correction threshold
-lambda.
Finds the smallest eigenvalue lambda of M1
(or M1
and M2
if supplied) and adds (threshold-lambda) to the diagonal to make it positive definite.