]> git.donarmstrong.com Git - ape.git/blobdiff - man/yule.time.Rd
final changes for ape 2.4 including removing mlphylo!
[ape.git] / man / yule.time.Rd
index 4bbe9526e6440145c3fca64b799aef619f9bade7..f67642b1db52f6e0d51f3c46d7d64ee8b1c7256e 100644 (file)
@@ -63,14 +63,18 @@ birth.step <- function(l1, l2, Tcl) { # 2 rates with one break-point
 BIRTH.logis <- function(t) log(exp(-a*t) + exp(b))/a + t
 BIRTH.step <- function(t)
 {
-    if (t <= Tcl) return(t*l1)
-    Tcl*l1 + (t - Tcl)*l2
+    out <- numeric(length(t))
+    sel <- t <= Tcl
+    if (any(sel)) out[sel] <- t[sel] * l1
+    if (any(!sel)) out[!sel] <- Tcl * l1 + (t[!sel] - Tcl) * l2
+    out
 }
 data(bird.families)
 ### fit both models:
 yule.time(bird.families, birth.logis)
 yule.time(bird.families, birth.logis, BIRTH.logis) # same but faster
 \dontrun{yule.time(bird.families, birth.step)}  # fails
-yule.time(bird.families, birth.step, BIRTH.step)
+yule.time(bird.families, birth.step, BIRTH.step,
+          opti = "nlminb", start = c(.01, .01, 100))
 }
 \keyword{models}