regularize_matrix: Regularize Matrix

Description Usage Arguments Value

View source: R/regularize_matrix.R

Description

Regularize a square matrix by manipulating it's diagonal

Usage

1
2
3
4
5
6
regularize_matrix(
  matr,
  const = 1,
  method = c("constant", "avg_diag", "increase_diag"),
  only_if_singular = TRUE
)

Arguments

matr

the matrix to be regularized

const

the constant to be used in the regularization

method

how to regularize the matrix. can be one of 'constant', 'avg_diag', 'increase_diag'. see details for more information.

only_if_singular

if true, will regularize only if the matrix is singular

Value

if method = 'constant', will add the constant to the diagonal. if method = 'avg_diag', will calculate a weighted average of the original matrix and an identity matrix multiplied by the avregae value of the diagonal, with weights 1 - const and const. if method = 'avg_diag', will calculate a weighted average of the original matrix and the diagonal of the matrix, with weights 1 - const and const


itamarfaran/corrpops documentation built on Dec. 20, 2021, 8:02 p.m.