Skip to content
Prev 248771 / 398506 Next

Positive Definite Matrix

On Jan 29, 2011, at 7:58 AM, David Winsemius wrote:

            
Just to be clear (since on the basis of some off-line communications  
it did not seem to be clear):  A real, symmetric matrix is Hermitian  
(and therefore all of its eigenvalues are real). Further, it is  
positive-definite if and only if its eigenvalues are all positive.

qwe<-c(2,-1,0,-1,2,-1,0,1,2)
q<-matrix(qwe,nrow=3)

isPosDef <- function(M) { if ( all(M == t(M) ) ) {  # first test  
symmetric-ity
                                 if (  all(eigen(M)$values > 0) ) {TRUE}
                                    else {FALSE} } #
                                 else {FALSE}  # not symmetric

                           }

 > isPosDef(q)
[1] FALSE
> isPosDef(m)
[1] TRUE

You might want to look at prior postings by people more knowledgeable  
than me:

http://finzi.psych.upenn.edu/R/Rhelp02/archive/57794.html

Or look at what are probably better solutions in available packages:

http://finzi.psych.upenn.edu/R/library/corpcor/html/rank.condition.html
http://finzi.psych.upenn.edu/R/library/matrixcalc/html/is.positive.definite.html