Find the nearest correlation matrix that is positive semi-definite.
The function iteratively adjust the correlation matrix by clipping the eigenvalues of a difference matrix. The diagonal elements are set to one.
Parameters: | corr : ndarray, (k, k)
threshold : float
n_fact : int or float
|
---|---|
Returns: | corr_new : ndarray, (optional)
|
See also
Notes
The smallest eigenvalue of the corrected correlation matrix is approximately equal to the threshold. If the threshold=0, then the smallest eigenvalue of the correlation matrix might be negative, but zero within a numerical error, for example in the range of -1e-16.
Assumes input correlation matrix is symmetric.
Stops after the first step if correlation matrix is already positive semi-definite or positive definite, so that smallest eigenvalue is above threshold. In this case, the returned array is not the original, but is equal to it within numerical precision.