]> git.donarmstrong.com Git - ape.git/blobdiff - R/ace.R
few corrections and fixes
[ape.git] / R / ace.R
diff --git a/R/ace.R b/R/ace.R
index 1dd0caa950b0c9bef4023b1c9024d9cb3fd92db8..f728ee7c6045f9478e21fa0edd1e12fafa5aa4fa 100644 (file)
--- a/R/ace.R
+++ b/R/ace.R
@@ -1,8 +1,8 @@
-## ace.R (2009-11-12)
+## ace.R (2010-02-03)
 
 ##   Ancestral Character Estimation
 
-## Copyright 2005-2009 Emmanuel Paradis and Ben Bolker
+## Copyright 2005-2010 Emmanuel Paradis and Ben Bolker
 
 ## This file is part of the R-package `ape'.
 ## See the file ../COPYING for licensing issues.
@@ -131,9 +131,10 @@ did not match: the former were ignored in the analysis.')
             }
             if (model == "SYM") {
                 np <- nl * (nl - 1)/2
-                rate[col(rate) < row(rate)] <- 1:np
+                sel <- col(rate) < row(rate)
+                rate[sel] <- 1:np
                 rate <- t(rate)
-                rate[col(rate) < row(rate)] <- 1:np
+                rate[sel] <- 1:np
             }
         } else {
             if (ncol(model) != nrow(model))
@@ -145,9 +146,10 @@ as the number of categories in `x'")
             np <- max(rate)
         }
         index.matrix <- rate
-        index.matrix[cbind(1:nl, 1:nl)] <- NA
-        rate[cbind(1:nl, 1:nl)] <- 0
-        rate[rate == 0] <- np + 1 # to avoid 0's since we will use this an numeric indexing
+        tmp <- cbind(1:nl, 1:nl)
+        index.matrix[tmp] <- NA
+        rate[tmp] <- 0
+        rate[rate == 0] <- np + 1 # to avoid 0's since we will use this as numeric indexing
 
         liks <- matrix(0, nb.tip + nb.node, nl)
         TIPS <- 1:nb.tip
@@ -222,7 +224,7 @@ anova.ace <- function(object, ...)
     table <- data.frame(ll, df, ddf, dev,
                         pchisq(dev, ddf, lower.tail = FALSE))
     dimnames(table) <- list(1:length(X), c("Log lik.", "Df",
-                                           "Df change", "Deviance",
+                                           "Df change", "Resid. Dev",
                                            "Pr(>|Chi|)"))
     structure(table, heading = "Likelihood Ratio Test Table",
               class = c("anova", "data.frame"))