7
$\begingroup$

Does anyone know how the eigenvalues are adjusted to make a non-positive definite matrix into a positive definite matrix in Matrix package? I mean in nearPD function.

$\endgroup$

1 Answer 1

8
$\begingroup$

The nearPD package uses the algorithm developed by Dr. Nick Higham and others. Higham describes the algorithm here (PDF): Higham, Nick (2002) Computing the nearest correlation matrix - a problem from finance; IMA Journal of Numerical Analysis 22, 329–343. In a nutshell, they are finding the "closest" (minimum difference in Frobenuis norm) positive semi-definite matrix whose values are constrained to $(-1, 1)$ and $1$'s on the diagonal.

$\endgroup$
5
  • $\begingroup$ nearPD doesn't seem to be available under R 3.1 is there an alternative? $\endgroup$
    – tim
    Feb 14, 2015 at 22:50
  • $\begingroup$ I'll try and contact Dr. Higham by e-mail, but in the interim, you can use something similar to what I describe in this blog post based on "nudging" the eigenvalues. $\endgroup$
    – Avraham
    Feb 16, 2015 at 0:26
  • 2
    $\begingroup$ Actually, it seems that the nearPD function is now part of the Matrix package, which should be in any install of R which includes recommended packages. $\endgroup$
    – Avraham
    Feb 16, 2015 at 0:29
  • $\begingroup$ Fantastic: thanks @Avraham Good to see base incorporating useful new functions from userworld to! $\endgroup$
    – tim
    Feb 16, 2015 at 8:39
  • 1
    $\begingroup$ BTW: nearPD() was "always" (well since 2007) in the Matrix package which has been part of R as "Recommended" included in (practically) all precompiled versions of R. $\endgroup$ Dec 3, 2022 at 16:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.