Does Mathematica have a way to "fix" a correlation matrix that is not positive semi-definite?
I looked through the documentation and search the internet but could not find anything.
|
Does Mathematica have a way to "fix" a correlation matrix that is not positive semi-definite? I looked through the documentation and search the internet but could not find anything. |
||||
|
|
|
Here is simple (unweighted) Mma version of the Matlab implementation of Covariance Bending.
examples:
Update: the previous method continues the iteration until all eigenvalues are at or above the threshold, that is, it does not check and stop if the current matrix is PD. The following is a version that tests for positive definiteness using
|
|||||||||||
|
|
I like the approach in this paper. Below is a starting point for an implementation.
Example :
|
||||
|
|
|
Generally, the reason why matrices that were supposed to be positive semi-definite but are not, is because the constraint of working in a finite precision world often introduces a wee bit of perturbation in the lowest eigenvalues of the matrix, making it either negative or complex. These errors are generally of the order of machine precision, but is enough to return
Now if this isn't sufficient to make your matrix positive semi-definite, you should go back and take a closer look at your problem to see if there are other reasons to not expect it to be positive semi-definite. |
|||||||
|