tag:blogger.com,1999:blog-8499895524521663926.post1105227932309547449..comments2019-08-21T09:33:02.172-04:00Comments on Phylogenetic Tools for Comparative Biology: Ancestral character estimation using likelihoodLiam Revellhttp://www.blogger.com/profile/04314686830842384151noreply@blogger.comBlogger2125tag:blogger.com,1999:blog-8499895524521663926.post-39796593120761681442011-12-08T11:59:56.281-05:002011-12-08T11:59:56.281-05:00Hi Dave.
Singular matrices have a determinant of ...Hi Dave.<br /><br />Singular matrices have a determinant of 0 and are non-invertible. In your example, vcv.phylo(tree1) is nonsingular, as you point out. However, ancestral character estimation uses the VCV matrix for all tips & internal nodes. (The phytools function that computes this is vcvPhylo.) In this case, the matrix will be singular if any terminal or internal edge lengths are zero. <i>However</i>, the matrix will not be singular in the latter case if we first collapse internal edges of zero length using multi2di(). (Unfortunately, anc.ML calls pic internally to get a starting estimate of σ so the present version will still fail, but for a different reason, if zero length internal edges are collapsed. I have fixed this and confirmed that anc.ML(multi2di(tree2),x) will work. I will post this updated version this afternoon.)<br /><br />Thanks for the comments. LiamLiam Revellhttps://www.blogger.com/profile/04314686830842384151noreply@blogger.comtag:blogger.com,1999:blog-8499895524521663926.post-62182858512207996632011-12-08T11:38:14.676-05:002011-12-08T11:38:14.676-05:00So, my friend Annat Haber and I were once having a...So, my friend Annat Haber and I were once having a discussion about how zero-length branches affect various analyses, as these are common byproducts of the various methods for timescaling paleontological trees. ace() complains that trees with zero-length branches have singular matrices, which really isn't true if you look at the eigenvalues of the vcv matrix (they are all positive). <br /><br />For example:<br /><br />set.seed(10)<br />tree<-rtree(10)<br />tree1<-tree;tree2<-tree<br />tree1$edge.length[6]<-0<br />tree2$edge.length[11]<-0<br />layout(matrix(1:3,,3));plot(tree);plot(tree1);plot(tree2) #I've collapsed a terminal edge in 1, an internal edge in 2<br />trait<-rnorm(10);names(trait)<-tree$tip.label<br />x<-ace(trait,tree) #no error<br />x1<-ace(trait,tree1) #error!<br />x2<-ace(trait,tree2) #error!<br /><br />I never got around to dissecting the code to find out why, however. So I tried your code.<br /><br />y<-anc.ML(tree,trait)<br />y1<-anc.ML(tree1,trait)<br />y2<-anc.ML(tree2,trait)<br /><br />Still complains the vcv matrix is singular. Maybe this is a problem with solve()?<br />-DaveDavid Bapsthttps://www.blogger.com/profile/17606476387441191531noreply@blogger.com