richfitz / diversitree

diversitree: comparative phylogenetic analyses of diversification
http://www.zoology.ubc.ca/prog/diversitree
30 stars 9 forks source link

Bug in custom root state with find.mle #14

Open richfitz opened 8 years ago

richfitz commented 8 years ago

Surprised that this is not tested, but it's a bug.

library(diversitree)
pars <- c(.1, .1, .03, .03, .1, .2)
set.seed(3)
phy <- trees(pars, "bisse", max.taxa=25, max.t=Inf, x0=0)[[1]]
#fitting a Mk2 model without and with root constraint
lik <- make.mk2(phy, phy$tip.state)
fit.mk2 <- find.mle(lik, c(.1, .1))
fit.mk2.root <- find.mle(lik,c(.1,.1), root=ROOT.GIVEN, root.p=c(0,1))
#fitting an ER model without and with root constraint
lik2=constrain(lik,q01~q10)
fit.er <- find.mle(lik2, 0.1)
fit.er.root <- find.mle(lik2, 0.1, root=ROOT.GIVEN, root.p=c(0,1), keep.func=TRUE) # error
fit.er.root <- find.mle(lik2, 0.1, root=ROOT.GIVEN, root.p=c(0,1), keep.func=FALSE)

Fix is just a bit off faffing in do.mle.search

Reported by Sébastien Lavergne