Hi Anna,
This should now be fixed on the github version. If you'd rather not
install that, just constrain your q10 to some "very small" value (e.g.
q10 ~ 1e-10):
library(diversitree)
pars <- c(.1, .1, .03, .03, .03, .06)
set.seed(1)
phy <- trees(pars, "bisse", max.taxa=50, max.t=Inf, x0=0)[[1]]
lik <- make.mk2(phy, phy$tip.state)
lik.m <- constrain( lik, q10 ~ 0 )
fit.m <- find.mle(lik.m, .1)
st <- asr.marginal(lik.m, coef(fit.m))
st
lik.m <- constrain( lik, q10 ~ 1e-10)
fit.m <- find.mle(lik.m, .1)
st <- asr.marginal(lik.m, coef(fit.m))
st
Cheers,
Rich
On 7 October 2013 23:12, Anna Rice wrote:
> Hello,
>
> I'm trying to use the package Diversitree to perform an ancestral
> reconstruction using a constrained Mk2 model.
> Unfortunately, after running the model and plotting the results I saw that
> most of the internal nodes did not get any state (NaN).
> Doing exactly the same without the constrain works fine and assigns a state
> for all internal nodes.
>
> Any idea why this happens?
>
> Here is the relevant part of code I was using:
>
> lik<-make.mk2(tree,states)
> lik.m <- constrain( lik, q10 ~ 0 )
> fit.m <- find.mle(lik.m, .1)
>
> st <- asr.marginal(lik.m, coef(fit.m)) #same if I use joint reconstruction
>
> And this is what I got for 31 nodes:
>> st
> [,1] [,2] [,3].[,23] [,24] [,25]
> [1,]1 NaN NaN NaN NaN NaN
> [2,]0 NaN NaN ... NaN NaN NaN
> [,26] [,27] [,28][,29] [,30] [,31]
> [1,] 0.1770124 0.02323889 0.001580509 0.0003160667 0.05889347 0.002819436
> [2,] 0.8229876 0.97676111 0.998419491 0.9996839333 0.94110653 0.997180564
>
>
> Thanks,
> Anna
>
> [[alternative HTML version deleted]]
>
> ___
> R-sig-phylo mailing list - R-sig-phylo@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
> Searchable archive at http://www.mail-archive.com/r-sig-phylo@r-project.org/
___
R-sig-phylo mailing list - R-sig-phylo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
Searchable archive at http://www.mail-archive.com/r-sig-phylo@r-project.org/