Usage
nearPD(x, corr = FALSE, keepDiag = FALSE, do2eigen = TRUE, doSym = FALSE,
doDykstra = TRUE, only.values = FALSE, only.matrix = TRUE, eig.tol = 1e-06,
conv.tol = 1e-07, posd.tol = 1e-08, maxit = 100, trace = FALSE)
Arguments
x
numeric n * n approximately positive definite matrix, typically an
approximation to a correlation or covariance matrix.
corr
logical indicating if the matrix should be a
correlation matrix.
keepDiag
logical, generalizing corr
: if TRUE
, the
resulting matrix should have the same diagonal (diag(x)
) as
the input matrix.
do2eigen
logical indicating if a posdefify
eigen step should be applied to the result of the Higham algorithm.
doSym
logical indicating if X <- (X + t(X))/2
should be done,
after X <- tcrossprod(Qd, Q)
. Some doubt if this is necessary.
doDykstra
logical indicating if Dykstra's correction should be used;
true by default. If false, the algorithm is basically the direct fixpoint
iteration $Y(k) = P_U(P_S(Y(k-1)))$.
only.values
logical; if TRUE
, the result is just the vector
of eigen values of the approximating matrix.
only.matrix
logical indicating if only the matrix should be returned.
eig.tol
defines relative positiveness of eigenvalues compared to
largest one, $\lambda_1$. Eigen values $\lambda_k$ are treated
as if zero when $\lambda_k / \lambda_1 = eig.tol$.
conv.tol
convergence tolerance for Higham algorithm.
posd.tol
tolerance for enforcing positive definiteness (in the
final posdefify
step when do2eigen
is TRUE
).
maxit
maximum number of iterations allowed.
trace
logical or integer specifying if convergence monitoring
should be traced.