Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

symm

Symmetrize matrix


Description

Function that symmetrizes matrices.

Usage

symm(M)

Arguments

M

(In numeric ideality symmetric) square matrix.

Details

Large objects that are symmetric sometimes fail to be recognized as such by R due to rounding under machine precision. This function symmetrizes for computational purposes matrices that are symmetric in numeric ideality.

Value

A symmetric matrix.

Author(s)

Carel F.W. Peeters <cf.peeters@vumc.nl>, Wessel N. van Wieringen

Examples

## 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]

## Obtain regularized precision under optimal penalty
OPT <- optPenalty.LOOCV(X, 10, 30, 10, target = diag(diag(1/covML(X))))

## Check symmetry
## OPT$optPrec is symmetric by definition
## But is not recognized as such due to rounding peculiarities
isSymmetric(OPT$optPrec)

## Symmetrize
symm(OPT$optPrec)

rags2ridges

Ridge Estimation of Precision Matrices from High-Dimensional Data

v2.2.4
GPL (>= 2)
Authors
Carel F.W. Peeters [cre, aut], Anders Ellern Bilgrau [aut], Wessel N. van Wieringen [aut]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.