emmanuelparadis / ape

analysis of phylogenetics and evolution

Home Page:http://ape-package.ird.fr/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

model fit suspicious: gradients apparently non-finite

xuechunxu opened this issue · comments

Hi,

I estimated ancestral character states for discretely valued traits. But got the error:
Error in matexpo(Q * EL[i]) : NA/NaN/Inf in foreign function call (arg 1) In addition: Warning messages: 1: In log(comp[-TIPS]) : NaNs produced 2: In ace(x, tree, model = "ER", type = "discrete") : model fit suspicious: gradients apparently non-finite

Here is my command line:
image
image

This is my niche file, these are five niche types
image

The input file:
ace.zip

Looking forward to your reply!

Chun Xu

Hi,
There are a few things you need to pay attention to:
1/ The function multi2di has the option random = TRUE by default which may not resolve the root of the tree correctly. You can set random = FALSE, but you are not sure about the output too. I suggest:

tree <- root(tree, ".....", resolve.root = TRUE)

where you replace "....." by the outgroup label.
2/ You certainly need to do the following transformation:

x[x == "DontKnow"] <- NA

See the explanation in ?ace about how missing values are treated by this function.
3/ It seems you need to transform the branch lengths of the tree. For instance:

tree2 <- compute.brlen(tree, 1)

This is quite common that non-ultrametric trees fail when input into ace. You may try different transformations (see ?compute.brlen and other functions in other packages like geiger or phytools). Then it's up to you to interpret these transformations with respect to your data.
Best,
Emmanuel

Thank you very much, it worked. The bug is caused that the length of some leaves being zero in my phylogenetic tree. Thank you again.