near_posdef: Nearest Positive-Definite Matrix

Description Usage Arguments Details Value References Examples

View source: R/cov-estim-help.R

Description

Implements the algorithm of \insertCitehigham2002computing;textualCovEstim to compute the nearest positive-definite matrix to an approximate one, typically a correlation or variance-covariance matrix.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
near_posdef(
  mat,
  corr = FALSE,
  keep_diag = FALSE,
  do_dykstra = TRUE,
  eig_tol = 1e-06,
  conv_tol = 1e-07,
  posd_tol = 1e-08,
  maxit = 100,
  trace = FALSE
)

Arguments

mat

a pxp matrix.

corr

a logical, indicating if the result should be a correlation matrix. Default value is FALSE.

keep_diag

a logical, indicating if the result should have the same diagonal as the original matrix mat.

do_dykstra

a logical, indicating if Dykstra's correlation is to be used. Default value is TRUE.

eig_tol

a double, defining the relative positiveness of eigenvalues compared to the largest eigenvalue. Default value is 1e-6.

conv_tol

a double, defining the convergence tolerance for the Higham algorithm. Default value is 1e-7.

posd_tol

a double, defining the tolerance for enforcing positive definiteness. Default value is 1e-8.

maxit

maximum number of iterations. Default value is 100.

trace

a logical, indicating whether iterations are to be traced (printed out). Default value is FALSE.

Details

Note that setting corr = TRUE just sets diag(.) <- 1 within the algorithm. The near_posdef() is originally found under \insertCitematrixpackage;textualCovEstim.

Value

a positive-definite matrix.

References

\insertAllCited

Examples

1
2
3
4
data(sp200)
sp_rets <- sp200[1:100,-1]
ml_sigma <- sigma_estim(sp_rets, "ML")
ml_sigma_near_posdef <- near_posdef(ml_sigma, eig_tol=1e-8)

antshi/CovEstim documentation built on Nov. 13, 2020, 2:25 p.m.