Skip to content

Commit

Permalink
clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
KlausVigo committed Dec 3, 2024
1 parent 6649fc1 commit 1704f7a
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 42 deletions.
2 changes: 1 addition & 1 deletion R/ancestral.R
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ ptree <- function(tree, data, acctran=TRUE, return = "prob", tips=FALSE, ...) {
f$traverse(edge)
tmp <- reorder(tree)$edge
tmp <- tmp[tmp[,2]>Ntip(tree),]
if(length(tmp)>0 && acctran==TRUE)f$acctran_traverse(tmp)
if(length(tmp)>0 && acctran)f$acctran_traverse(tmp)
res <- res_state <- vector("list", nNode)
res <- vector("list", m)
att$names <- c(tree$tip.label, tree$node.label) #makeAncNodeLabel(tree, ...)
Expand Down
41 changes: 0 additions & 41 deletions R/phylo.R
Original file line number Diff line number Diff line change
Expand Up @@ -636,47 +636,6 @@ guess_model <- function(x){
}


# needs to go in phangorn extra
optEdgeMulti <- function(object, control = pml.control(epsilon = 1e-8,
maxit = 10, trace = 1, tau = 1e-8), ...) {
tree <- object$tree
theta <- object$tree$edge.length
weight <- attr(object$data, "weight")
ll0 <- object$logLik
eps <- 1
iter <- 0
iter2 <- 0
scale <- 1
# l <- length(theta)
while (abs(eps) > control$eps && iter < control$maxit) {
dl <- score(object)
thetaNew <- log(theta) + scale * solve(dl[[2]], dl[[1]]) # + diag(l) * 1e-10
newtheta <- exp(thetaNew)
tree$edge.length <- as.numeric(newtheta)
object <- update(object, tree = tree)
ll1 <- object$logLik
eps <- (ll0 - ll1) / ll1
if (eps < 0) {
newtheta <- theta
scale <- scale / 2
tree$edge.length <- as.numeric(theta)
ll1 <- ll0
iter2 <- iter2 + 1
}
else {
scale <- 1
iter2 <- 0
}
theta <- newtheta
if (iter2 == 0 && control$trace > 0) cat("loglik: ", ll1, "\n")
ll0 <- ll1
if (iter2 == 10) iter2 <- 0
if (iter2 == 0) iter <- iter + 1
}
object <- update(object, tree = tree)
object
}


# add data for internal use parent.frame(n) for higher nestings
# update.pmlNew <- function(object, ..., evaluate = TRUE) {
Expand Down

0 comments on commit 1704f7a

Please sign in to comment.