m
, construct a "close" positive definite
one.posdefify(m, method = c("someEVadd", "allEVadd"),
symmetric, eigen.m = eigen(m, symmetric= symmetric),
eps.ev = 1e-07)
eigen
(unless
eigen.m
is specified).eigen
value decomposition of
m
, can be specified in case it is already available.diag
) as m
but with the property to
be positive definite. When the smallest eigenvalue $\lambda_n$ are less than
Eps <- eps.ev * abs(lambda[1])
, i.e., negative or >= Eps
) values,
$\tilde\Lambda_{j,j} = \tilde\lambda_j$.
Then, $\tilde m = V \tilde\Lambda V'$ is computed
and rescaled in order to keep the original diagonal (where that is
>= Eps
).
Cheng, Sheung Hun and Higham, Nick (1998) A Modified Cholesky Algorithm Based on a Symmetric Indefinite Factorization; SIAM J. Matrix Anal. Appl., 19, 1097--1110.
Knol DL, ten Berge JMF (1989) Least-squares approximation of an improper correlation matrix by a proper one. Psychometrika 54, 53--61.
Highham (2002) Computing the nearest correlation matrix - a problem from finance; IMA Journal of Numerical Analysis 22, 329--343.
Lucas (2001) Computing nearest covariance and correlation matrices. A thesis submitted to the University of Manchester for the degree of Master of Science in the Faculty of Science and Engeneering.
eigen
on which the current methods rely.
nearPD()
in the set.seed(12)
m <- matrix(round(rnorm(25),2), 5, 5); m <- 1+ m + t(m); diag(m) <- diag(m) + 4
m
posdefify(m)
1000 * zapsmall(m - posdefify(m))
Run the code above in your browser using DataLab