Hi Jonathan, you probably mixed up positive matrices and positive definite matrices. To have only positive eigen values a matrix must be positive definite. Covariance matrices are for example are always positive semi-definite, even though they can contain negative entries. D is symmetric therefore all eigen values are reel and positive therefore the largest eigen value is positive (Perron–Frobenius theorem).
Regards Klaus On 9/27/11, Jonathan Mitchell <jonsmit...@gmail.com> wrote: > Hello! > > I tried on some simulated trees last night and they weren't working, but > after your message I started a fresh R session and now solve() works fine > for both my ultrametric tree, and my simulated trees. No idea what happened > there, but thanks! > > Unfortunately, I still am getting almost all negative eigenvalues for the > decomposition of the distance matrix, which doesn't make sense to me. I was > under the impression that the distance matrix from an ultrametric tree > should be Euclidean. Further, I can confirm that the distance matrix is > supposed to be euclidean by using the is.euclid() function from ade4 > [is.euclid(as.dist(D)) returns "TRUE"], which means I have no idea why > eigen(D) is giving me negative eigenvalues... > > Any thoughts? > > --Jon > > On Tue, Sep 27, 2011 at 12:23 AM, Emmanuel Paradis > <emmanuel.para...@ird.fr>wrote: > >> Hi John, >> >> I tried with a couple of simulated trees (ultrametric or not) and got no >> error. Have you tried using the 'tol' argument of solve()? >> >> Emmanuel >> -----Original Message----- >> From: Jonathan Mitchell <mitchel...@uchicago.edu> >> Sender: r-sig-phylo-boun...@r-project.org >> Date: Mon, 26 Sep 2011 17:42:49 >> To: <r-sig-phylo@r-project.org> >> Reply-To: jonsmit...@gmail.com >> Subject: [R-sig-phylo] Negative Eigenvalues from Phylo Distance Matrix >> >> Hello all, >> >> I've run into a problem trying to find the eigen vectors for a >> phylogenetic >> distance matrix. Namely, the transposed vector matrix crossed with the >> matrix itself is singular. Also, the eigenvalues for the distance matrix >> proper are almost all negative, which I don't understand whatsoever. >> >> #Given a tree with branch lengths (in my case, it's ultrametric) >> D <- cophenetic(tree) >> eD <- eigen(D, symmetric=TRUE)$vectors #note that all elements except the >> first in eD$values are negative for me >> inv <- solve(t(eD)%*%eD) #this is what I really want, the inverse of the >> transposed matrix of vectors multiplied by itself >> >> Error in solve.default(t(eD) %*% eD) : >> system is computationally singular: reciprocal condition number = >> 2.46807e-29 >> >> Any help would be greatly appreciated! >> >> -- Jon >> >> _____ >> >> Jonathan S. Mitchell >> http://home.uchicago.edu/~mitchelljs/ >> >> PhD Student >> Committee on Evolutionary Biology >> The University of Chicago >> 1025 57th Str, Culver Hall 402 >> Chicago, IL 60637 >> >> Geology Department >> The Field Museum of Natural History >> 1400 S. Lake Shore Dr. >> Chicago, IL 60605 >> >> [[alternative HTML version deleted]] >> >> _______________________________________________ >> R-sig-phylo mailing list >> R-sig-phylo@r-project.org >> https://stat.ethz.ch/mailman/listinfo/r-sig-phylo >> > > [[alternative HTML version deleted]] > > _______________________________________________ > R-sig-phylo mailing list > R-sig-phylo@r-project.org > https://stat.ethz.ch/mailman/listinfo/r-sig-phylo > -- Klaus Schliep Université Paris 6 (Pierre et Marie Curie) 9, Quai Saint-Bernard, 75005 Paris _______________________________________________ R-sig-phylo mailing list R-sig-phylo@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-phylo