statsmodels.stats.correlation_tools.corr_clipped(corr, threshold=1e15)
[source]
Find a near correlation matrix that is positive semidefinite
This function clips the eigenvalues, replacing eigenvalues smaller than the threshold by the threshold. The new matrix is normalized, so that the diagonal elements are one. Compared to corr_nearest, the distance between the original correlation matrix and the positive definite correlation matrix is larger, however, it is much faster since it only computes eigenvalues once.
Parameters: 


Returns: 
corr_new – corrected correlation matrix 
Return type: 
ndarray, (optional) 
The smallest eigenvalue of the corrected correlation matrix is approximately equal to the threshold
. In examples, the smallest eigenvalue can be by a factor of 10 smaller than the threshold, e.g. threshold 1e8 can result in smallest eigenvalue in the range between 1e9 and 1e8. 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 1e16.
Assumes input correlation matrix is symmetric. The diagonal elements of returned correlation matrix is set to ones.
If the correlation matrix is already positive semidefinite given the threshold, then the original correlation matrix is returned.
cov_clipped
is 40 or more times faster than cov_nearest
in simple example, but has a slightly larger approximation error.
See also
© 2009–2012 Statsmodels Developers
© 2006–2008 Scipy Developers
© 2006 Jonathan E. Taylor
Licensed under the 3clause BSD License.
http://www.statsmodels.org/stable/generated/statsmodels.stats.correlation_tools.corr_clipped.html