extreme_eig: Utilities for regularization of a matrix
Description
regularize can be used to regularize (nearly-)singular correlation matrices. It may also be used to regularize covariance matrices but will not keep their diagonal constant. Use on other types of matrices may give nonsense. The regularization corrects the diagonal of matrices with high condition number so that the condition number of a corrected matrix is the maximum value specified by maxcondnum. For that purpose, it needs the extreme eigenvalues of the matrix, by default provided by the function extreme_eig. Calls functions from RSpectra if available, and falls back on base functions otherwise.
extreme_eig returns a vector of length 2, the largest and the smallest eigenvalues in this order.
regularize returns a matrix, possibly in sparse format.
Arguments
M
Square matrix. Sparse matrices of class d[s|g]CMatrix (and some others too) are handled (some vagueness, as if it fails for some matrix types, an alternative function shoudl be easy to define based on this one as template.
A
Square matrix as M, assumed symmetric.
symmetric
Whether the matrix is symmetric. Helpful to select efficient methods for this case if the matrix class does not implies its symmetry.
required
Whether the computation should be attempted independently of the size of the matrix.
EEV
Two extreme eigenvalue in the return format of extreme_eig
maxcondnum
Target condition number when regularization is performed