Function that evaluates various numerical properties of a square input matrix. The intended use is to evaluate the various numerical properties of what is assumed to be a covariance matrix. Another use is to evaluate the various numerical properties of a (regularized) precision matrix.
evaluateS(S, verbose = TRUE)
Covariance or (regularized) precision matrix
.
A logical
indicating if output should be printed on
screen.
A logical
indicating if the matrix is symmetric.
A logical
indicating if the eigenvalues are real.
A logical
indicating if the eigenvalues are strictly
positive.
A logical
indicating if the matrix is diagonally
dominant.
A numerical
giving the value of the trace.
A numerical
giving the value of the determinant.
A numerical
giving the value of the spectral
condition number.
The function evaluates various numerical properties of a covariance or precision input matrix. The function assesses if the input matrix is symmetric, if all its eigenvalues are real, if all its eigenvalues are strictly positive, and if it is a diagonally dominant matrix. In addition, the function calculates the trace, the determinant, and the spectral condition number of the input matrix. See, e.g., Harville (1997) for more details on the mentioned (numerical) matrix properties.
Harville, D.A.(1997). Matrix algebra from a statistician's perspective. New York: Springer-Verlag.
## Obtain some (high-dimensional) data
p = 25
n = 10
set.seed(333)
X = matrix(rnorm(n*p), nrow = n, ncol = p)
colnames(X)[1:25] = letters[1:25]
Cx <- covML(X)
## Evaluate numerical properties covariance matrix
## Obtain, e.g., value trace
Seval <- evaluateS(Cx); Seval
#> Properties of input matrix:
#> ----------------------------------------
#> symmetric : TRUE
#> eigenvalues real : TRUE
#> eigenvalues > 0 : FALSE
#> diag. dominant : TRUE
#>
#> trace : 21.55145
#> determinant : 0
#> l2 cond. number : 2.694993e+16
#> ----------------------------------------
#> $symm
#> [1] TRUE
#>
#> $realEigen
#> [1] TRUE
#>
#> $posEigen
#> [1] FALSE
#>
#> $diagDom
#> [1] TRUE
#>
#> $trace
#> [1] 21.55145
#>
#> $det
#> [1] -2.78594e-255
#>
#> $condNumber
#> [1] 2.694993e+16
#>
Seval$trace
#> [1] 21.55145
## Evaluate numerical properties precision matrix after regularization
P <- ridgeP(Cx, lambda = 10, type = 'Alt')
Peval <- evaluateS(P); Peval
#> Properties of input matrix:
#> ----------------------------------------
#> symmetric : TRUE
#> eigenvalues real : TRUE
#> eigenvalues > 0 : TRUE
#> diag. dominant : TRUE
#>
#> trace : 19.8448
#> determinant : 0.00211
#> l2 cond. number : 1.95384
#> ----------------------------------------
#> $symm
#> [1] TRUE
#>
#> $realEigen
#> [1] TRUE
#>
#> $posEigen
#> [1] TRUE
#>
#> $diagDom
#> [1] TRUE
#>
#> $trace
#> [1] 19.8448
#>
#> $det
#> [1] 0.002113186
#>
#> $condNumber
#> [1] 1.953842
#>