extreme_eig: Utilities for regularization of a matrix

View source: R/correlationFns.R

extreme_eigR Documentation

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.

Usage

extreme_eig(M, symmetric, required = TRUE)
regularize(A, EEV=extreme_eig(A,symmetric=TRUE), maxcondnum=1e12)

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

Value

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.

Examples

H10 <- Matrix::Hilbert(10)
extreme_eig(H10,symmetric=TRUE) # ratio > 1e13
rH10 <- regularize(H10)
extreme_eig(rH10,symmetric=TRUE)  # ratio = 1e12

spaMM documentation built on Aug. 30, 2023, 1:07 a.m.

Related to extreme_eig in spaMM...